我知道已经有类似的问题,但所有答案大多数都是“哦,我忘记在结尾处加上斜杠了”。但这真的让我疯了。我正在尝试从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://S并寻找通配符,但我无法解决此错误... 欢迎提供任何帮助。