LaunchWebAuthFlow with Spotify return "Login page cannot be loaded"

I registered my application on Spotify. I made sure the URI is added to my registered application. But still, every time I run this code, I still get the same error. I also manage this in the background, so I know that it is not. What am I doing wrong?

I also tried switching /spotify to /provider_cb .

 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); }); 

Here's my driver license:

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

The first time I launch my application after restarting Chrome, the login page appears, as if everything is in order, but after logging in I still get the same error:

 identity.launchWebAuthFlow: Authorization page could not be loaded. 
+6
source share
2 answers

you can use

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

getRedirectUrl will return the URL with / at the end. so your source code led:

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

Instead, you can pass the endpoint as an argument to form the URL

+6
source

The getRedirectURL method getRedirectURL overloaded for the path, so you do not need to add a line.

 var redirectUri = chrome.identity.getRedirectURL('spotify') 
0
source

Source: https://habr.com/ru/post/982302/


All Articles