6

我在Spotify上注册了我的应用程序。我确信我已将URI添加到我的注册应用程序中。但仍然每次运行此代码时,我都会收到相同的错误。我也在后台运行,所以我知道不是这样。我究竟做错了什么?用Spotify启动WebAuthFlow返回“无法加载授权页面”

另外我试着用/provider_cb转换/spotify

var client_id = '<my_client_id>'; 
var redirectUri = chrome.identity.getRedirectURL() + "/spotify"; 

chrome.identity.launchWebAuthFlow({ 
    "url": "https://accounts.spotify.com/authorize?client_id="+client_id+ 
     "&redirect_uri="+ encodeURIComponent(redirectUri) + 
     "&response_type=token", 
    'interactive': true, 
}, 
function(redirect_url) { 
    console.log(redirect_url); 
}); 

这里是我的权限:

"permissions": [ 
    "http://*/*", "tabs", "webNavigation", "activeTab", "storage", "identity", 
    "declarativeContent", "https://accounts.spotify.com/*", 
    "https://accounts.spotify.com/authorize/*" 
] 

在我第一次重新启动Chrome浏览器后运行我的应用程序,在登录页面弹出像一切都很好,但我还是登录我后得到同样的错误:

identity.launchWebAuthFlow: Authorization page could not be loaded. 
+0

尝试从权限URL中删除'/',以便它是'“https://accounts.spotify.com/authorize*”'。 – abraham 2015-02-11 05:07:28

+0

没有什么区别:( – 2015-02-11 06:24:15

+1

为什么你在''redirectUri''上附加'“/ spotify''?你可能想尝试一下。 此外,'chrome.identity.getRedirectURL()'返回类似https:/ /hmjkmjkepdijhoojdojkdfohbdgmmhki.chromiumapp.org/,所以你可能会遇到双斜杠问题。 – 2015-02-11 10:15:42

回答

6
var redirectUri = chrome.identity.getRedirectURL() + "/spotify"; 

应该

var redirectUri = chrome.identity.getRedirectURL() + "spotify"; 

getRedirectUrl会在最后返回一个带有/的url。因此您的原始代码导致:

"https://<app_id>.chromiumapp.org//spotify"