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"