Unsupported grant type error when requesting access_token on Spotify API with Meteor HTTP
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) {
...
});