Open ranveerkunal opened 5 years ago
I managed to make a similar scenario work do you see any description at the error?
I think you're missing the content type in your header:
('Content-Type', 'application/x-www-form-urlencoded')
- Have your application request refresh and access tokens; Spotify returns access and refresh tokens When the authorization code has been received, you will need to exchange it with an access token by making a POST request to the Spotify Accounts service, this time to its /api/token endpoint: POST https://accounts.spotify.com/api/token The body of this POST request must contain the following parameters encoded in ´application/x-www-form-urlencoded as defined in the OAuth 2.0 specification:
relevant documentation: https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow
Typically one of the most common bugs we see is the Redirect URIs have a trailing slash in one place, and don't in others. They must be the exact same Redirect URL including the trailing slash everywhere, and most times that seems to resolve the issue.
Can you let me know if this has resolved your issue @ranveerkunal?
I have my Redirect URI correctly set up in the console.
Issue found on December 11th 2018.
Endpoint(s):
Scope(s):
Steps to reproduce:
let authOptions = { url: 'https://accounts.spotify.com/api/token', form: { 'grant_type': 'authorization_code', 'code': code, 'redirect_uri': redirectUri }, headers: { 'Authorization': 'Basic ' + (new Buffer(clientId + ':' + clientSecret).toString('base64')) }, json: true };
Expected behaviour:
return token
Actual behaviour:
400 Server Error (consistently)