且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 Meteor HTTP 在 Spotify API 上请求 access_token 时不支持的授权类型错误

更新时间:2022-06-27 07:06:10

您需要使用 params 而不是 data.因此,您的代码将是:

You need to use params instead of data. Thus, your code would be:

HTTP.post("https://accounts.spotify.com/api/token", {
  params: {
    grant_type : "authorization_code",
    code : authCode,
    redirect_uri : Router.routes['redirect_spotify'].url()
  },
  headers: {
    'Authorization' : "Basic " + CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse("xxxx:yyyyy")),
    'Content-Type':'application/x-www-form-urlencoded'
  }
}, function(error, result) {
   ...
});