【发布时间】:2020-06-11 00:34:27
【问题描述】:
我正在使用 api 尝试通过访问令牌获取我的个人资料数据。我使用了网站中给出的授权示例代码中的给定代码,并且我使用了
let parsed = queryString.parse(window.location.search);
let accessToken = parsed.access_token;
console.log(parsed);
console.log(accessToken);
fetch('https://api.spotify.com/v1/me', {
headers: {'Authorization': 'Bearer' + accessToken},
json: true
}).then((res) => res.json())
.then(data => console.log(data));
}
但即使访问令牌有效,400 错误仍然出现。我什至检查了该特定功能的 try it 方法,并且使用相同的标记,它能够获取数据。对于我在身份验证示例代码中更改的相关信息,我更改了 redirect_uri = "localhost:8888/callback" 然后我也更改了
res.redirect('http://localhost:3000/profile/?' +
querystring.stringify({
access_token: access_token,
refresh_token: refresh_token
}));
}
转到我的应用程序的个人资料页面。我想知道我是否需要以某种方式授予我的个人资料页面的权限,但我已经将其添加到重定向 url 以防万一。 感谢阅读
【问题讨论】: