用Spotify启动WebAuthFlow返回“授权页面无法加载” [英] launchWebAuthFlow with Spotify returns "Authorization page could not be loaded"

查看:208
本文介绍了用Spotify启动WebAuthFlow返回“授权页面无法加载”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Spotify上注册了我的应用程序。我确信我已将URI添加到我的注册应用程序中。但仍然每次运行此代码时,我都会收到相同的错误。我也在后台运行,所以我知道不是这样。我在做什么错了?

I registered my app on Spotify. I made sure I had the URI added to my registered app. But still every time I run this code I keep getting the same error. I am also running this in the background so I know it's not that. What am I doing wrong?

另外我尝试用 / provider_cb 替换 / spotify / code>。

Also I tried switching /spotify with /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 are my permissions:

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

在重新启动Chrome后第一次运行我的应用程序时,登录页面会弹出一切很好,但在登录后我仍然得到相同的错误:

On the first time I run my app after restarting Chrome, the sign-in page pops up like everything is fine, but after I log in I still get the same error:

identity.launchWebAuthFlow: Authorization page could not be loaded.


推荐答案

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

应该是

should be

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

getRedirectUrl将在末尾返回带有/的url。因此您的原始代码导致:

getRedirectUrl will return a url with a / at the end. so your original code was resulting in:

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

这篇关于用Spotify启动WebAuthFlow返回“授权页面无法加载”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆