Issue
I want to get an access token from the Spotify api Here is my request :
this.http.post("https://accounts.spotify.com/api/token", {
headers: {
'Authorization' : "Basic " + CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse("ID:Secret")),
'Content-Type':'application/x-www-form-urlencoded'
},
params: {
grant_type : "authorization_code",
code : code,
redirect_uri : "REDIRECT URL"
}
}).subscribe(data => {
console.log(data)
})
I get this error in the console:
"Http failure response for https://accounts.spotify.com/api/token: 415 OK"
Solution
I think you have to create a HttpParams
object with the params before, like:
let httpParams = new HttpParams()
.append("grant_type", "authorization_code")
.append("code", "code")
.append("redirect_uri", "redirect_uri");
this.http.post("https://accounts.spotify.com/api/token", httpParams.toString(), {
headers: {
'Authorization' : "Basic " + CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse("ID:Secret")),
'Content-Type':'application/x-www-form-urlencoded'
}
}).subscribe(data => {
console.log(data)
})
Answered By - Nicolas
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.