thelinmichael / spotify-web-api-node

A Node.js wrapper for Spotify's Web API.
http://thelinmichael.github.io/spotify-web-api-node/
MIT License
3.11k stars 497 forks source link

authorizationCodeGrant return bad request #127

Open valentinflausse opened 7 years ago

valentinflausse commented 7 years ago

Hi there, i made a facebook messenger chatbot with spotify issues.

My chatbot use a webview (webapp) to connect and grant authorization code with scope. When the user accept it, i insert the authorization code in my db.

(later) if my chatbot's user ask me to create a playlist for example, i get the user's authorization code, and use it to obtain an accesstoken like this :

https://codepen.io/vflausse/pen/OmEmJa

this code return me :

Something went wrong authorizationCodeGrant! { [WebapiError: Bad Request] name: 'WebapiError', message: 'Bad Request', statusCode: 400 }

Am i doing something wrong ? Did i have to request authorization (with spotify authorize) for any actions of my user, to grant a good authorize code and access token ?

Do you have an idea ? (Help will be really appreciated.) Thank you.

valentinflausse commented 7 years ago

Hello, could you take a look at my issue ? I will be very thankfull

vpicone commented 7 years ago

How are you getting the spotifyAC into your database? When you log the access code what do you get?Need more perspective on this, perhaps upload the project to Github?

fan1200 commented 7 years ago

Hi,

I had the same issue, just make sure to include the client secret in your setup. That worked for me.

        var spotifyApi = new SpotifyWebApi({
            redirectUri : redirectUri,
            clientId : clientId,
            clientSecret: clientSecret
        });