Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript chrome.identity.getRedirectURL在不同的计算机上具有不同的应用程序id_Javascript_Google Chrome_Authentication_Google Chrome Extension_Oauth - Fatal编程技术网

Javascript chrome.identity.getRedirectURL在不同的计算机上具有不同的应用程序id

Javascript chrome.identity.getRedirectURL在不同的计算机上具有不同的应用程序id,javascript,google-chrome,authentication,google-chrome-extension,oauth,Javascript,Google Chrome,Authentication,Google Chrome Extension,Oauth,为了让OAUTH工作,每次我在不同的计算机上运行它时,get重定向url都会更改 var redirectUri = chrome.identity.getRedirectURL("https://www.google.com/"); 这是我用来生成它的代码,但它返回的应用程序id以*.的形式,在不同的计算机上有不同的应用程序id 这是一个问题,因为我必须在我使用的API站点上注册重定向url,但每个人的重定向url都不同 这是完整的代码块 var redirectUri = chrome.

为了让OAUTH工作,每次我在不同的计算机上运行它时,get重定向url都会更改

var redirectUri = chrome.identity.getRedirectURL("https://www.google.com/"); 
这是我用来生成它的代码,但它返回的应用程序id以*.的形式,在不同的计算机上有不同的应用程序id

这是一个问题,因为我必须在我使用的API站点上注册重定向url,但每个人的重定向url都不同

这是完整的代码块

var redirectUri = chrome.identity.getRedirectURL("https://www.google.com/"); 
var auth_url = "https://accounts.spotify.com/authorize?client_id=" + client_id + "&redirect_uri=" + redirectUri + "&scope=user-library-modify%20user-read-email&response_type=token&state=123";
chrome.identity.launchWebAuthFlow({'url':auth_url,'interactive':true}, function(redirect_url){
    console.log(redirect_url)
});

硬编码也不起作用

仅当您将扩展加载为未打包时,应用程序ID才会更改,并且

有两种方法可以锁定ID:

  • 将其发布到Web应用商店。这将锁定从应用商店安装的用户的ID
  • 在清单中添加一个
    “key”
    字段。这是一个很好的切入点

  • 再次感谢Xan!你是如何像在chrome扩展和javascript方面那样学到很多东西的?你似乎已经回答了Sohone上几乎所有的Chrome扩展问题。很遗憾,我不知道。我刚开始回答有关扩展和应用程序的问题。在这个过程中,我学到了很多。