Pet*_*rtz 9 spotify oauth-2.0 meteor
我一直在尝试在MeteorJS中重新创建spotify oauth连接.我已经获得了请求访问和刷新令牌,但我现在仍然收到415错误.这是相关代码:
var results = HTTP.post(
'https://accounts.spotify.com/api/token',
{
data: {
code: code,
redirect_uri: redirectURI,
grant_type: 'authorization_code',
client_id: clientID,
client_secret: clientSecret
},
headers: {
'Content-Type':'application/json'
}
}
);
Run Code Online (Sandbox Code Playgroud)
我似乎无法在此演示中找到问题和代码的任何其他良好文档:
https://github.com/spotify/web-api-auth-examples/tree/master/authorization_code
工作得很好.
Kir*_*rby 12
我有类似的问题(但在Java中).类似的解决方案是
headers: {
'Content-Type':'application/x-www-form-urlencoded'
}
Run Code Online (Sandbox Code Playgroud)
Mar*_*ngh -5
如果您在客户端执行此操作,则它不起作用,因为由于同源策略,您不允许从客户端发布到另一个域。
如果这是服务器端,我建议使用预先存在的 spotify api npm 模块,而不是编写自己的请求。npmjs.org上有很多 Spotify API 实现。
使用 arunoda 的npm 包将 npm 包集成到您的 Meteor 应用程序中
| 归档时间: |
|
| 查看次数: |
4633 次 |
| 最近记录: |