【发布时间】:2018-10-15 21:57:40
【问题描述】:
我知道已经有类似的问题,但所有的答案大多是“哦,我忘了把斜线放在最后”但这绝对让我发疯。我试图从 Spotify API 获取访问令牌,但我不断收到无效的重定向 uri 错误。
这是我的 api 调用
const request = require('superagent');
const data = {
grant_type: 'authorization_code',
code: code,
// redirect_uri: encodeURIComponent('http://localhost:3000/Test')
redirect_uri: 'http://localhost:3000/Test'
};
request.post('https://accounts.spotify.com/api/token')
.set({
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + base64.encode(configs.client_id + ':' + configs.client_secret)
})
.send(data)
.end((err, tokenRes) => {
if (tokenRes) {
res.send({token: tokenRes})
} else {
res.error(err);
}
});
这些是我列入白名单的 URI:
http://localhost:3000/LoginRedirect
我在白名单中添加了很多组合,末尾带有斜杠,http:// 已删除搜索通配符,但我无法摆脱此错误...感谢任何帮助。
【问题讨论】:
标签: javascript express spotify