R
Railway14mo ago
xgloser

Issue with connecting to Spotify API (not happening locally)

Hi, I have deployed my app frontend react app deployed using one service and backend express using another service. The app connects to the Spotify API without issue locally however, since deploying it, I'm getting an error saying a param is missing - it's definitely there in the code as its tested and working correctly locally. Does anyone have any advice on how to diagnose? This is my first time building and deploying my own app, so really confused as to how/why its working without issue locally. Thanks Response Data: { error: 'unsupported_grant_type', error_description: 'grant_type parameter is missing' }
23 Replies
Percy
Percy14mo ago
Project ID: 34f17a45-feb3-4ab0-a644-8b2f55807382
xgloser
xgloser14mo ago
34f17a45-feb3-4ab0-a644-8b2f55807382 I'm also getting this message in the console and not sure if it's related VM10:5 crbug/1173575, non-JS module files deprecated.
Brody
Brody14mo ago
do you think you can share your repo?
xgloser
xgloser14mo ago
https://github.com/casey-turner/jams-playlist-generator/tree/deploy sure - it's here ^^^ I'm working on this deploy branch as I have been trying to debug and don't want to mess with things too much when I know it's been working locally
GitHub
GitHub - casey-turner/jams-playlist-generator at deploy
JAMS is a playlist creation tool powered by AI. With just a few simple steps, you can create and save your perfect playlist directly to your Spotify account. - GitHub - casey-turner/jams-playlist-g...
xgloser
xgloser14mo ago
I know with the Spotify API you need to register your redirect URI, which I've done http://localhost:3000/callback https://jams-playlist-generator-production.up.railway.app/callback <= this is my backend url
Brody
Brody14mo ago
i assume the backend talks to Spotify?
xgloser
xgloser14mo ago
yea, thats right its failing on connecting the users account to Spotify - so the very first step really
Brody
Brody14mo ago
just to cut down on my search, where would the code that does that be?
Brody
Brody14mo ago
so here you set the content type to application/x-www-form-urlencoded https://github.com/casey-turner/jams-playlist-generator/blob/main/packages/server/src/apis/spotifyApi.ts#L14 but then here, doesn't this encode the body as json? https://github.com/casey-turner/jams-playlist-generator/blob/main/packages/server/src/controllers/spotifyAuthController.ts#L39 as for why it works locally, zero clue lol
xgloser
xgloser14mo ago
sorry which bit are you saying encodes the body as json? (still really new to coding and obvs quite confused)
Brody
Brody14mo ago
you passed an object into spotifyTokenApi.post doesn't that encode that object into a json string for the body of that post request? this is also a question, since im not familiar with axios if im right, this would be an issue since you cant post a json body to an endpoint that expects x-www-form-urlencoded
xgloser
xgloser14mo ago
amazing, thanks for your help -I'll give that a shot now
Brody
Brody14mo ago
let me know how it goes
xgloser
xgloser14mo ago
IT WORKED!! thanks so much !!
Want results from more Discord servers?
Add your server