1

I am trying to do spotify login via the expo-auth-session on my expo app In the expo-auth-session doc, https://docs.expo.dev/guides/authentication/#spotify

I understand that the auth code flow gives me the authorization code in the response, and the implicit flow gives me the access token in the response. Neither flow gives me the aDoes anyone know how to get the refresh token?

I tried calling the refresh token endpoint using the authorization code that I got from the auth code flow, but it didn't work.

Jayden Yu
  • 41
  • 3

1 Answers1

-1

You can get refresh token by curl

curl -d client_id={CLIENT_ID} \
-d client_secret={CLIENT_SECRET} \
-d grant_type=authorization_code \
-d code={CODE} \
-d redirect_uri={REDIRECT_URI} \
https://accounts.spotify.com/api/token

enter image description here

Step 1 - create your application

Create your App in Spotify Developer Dashboard

Get Client ID, Client Secret and add redirect URIs

enter image description here enter image description here

Step 2 - Get code

https://accounts.spotify.com/authorize?response_type=code&client_id={your client id}&scope=user-read-email&redirect_uri={your redirect URL, mine is http://localhost:3000}

Browser will show code in the address control, copy the code part.

enter image description here

Step 3 - Get refresh

Get refresh code by curl from terminal

curl -d client_id={your client it} \
-d client_secret={your client secret} \
-d grant_type=authorization_code \
-d code={code from Step #2} \
-d redirect_uri=http://localhost:3000 \
https://accounts.spotify.com/api/token | jq

You can get the refresh token

{
  "access_token": "BQC...V-1"
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "AQA...6twR
  "scope": "user-read-email"
}

Reference

How to create a Spotify refresh token the easy way

Bench Vue
  • 5,257
  • 2
  • 10
  • 14