Skip to content

Instantly share code, notes, and snippets.

@Uvacoder
Forked from skidoodle/spotify.md
Created June 16, 2024 22:10
Show Gist options
  • Select an option

  • Save Uvacoder/ea5b5bf0ac740b0e9782d0085ab2aaac to your computer and use it in GitHub Desktop.

Select an option

Save Uvacoder/ea5b5bf0ac740b0e9782d0085ab2aaac to your computer and use it in GitHub Desktop.
How to get your Spotify tokens
  1. Create an application in the Spotify Developer Dashboard
    • Click on the Edit settings button
    • Set the Redirect URIs to a convenient location (doesn't matter)
    • Save the given Client ID along with the Client Secret
  2. Retrieve the access code
    • Visit the following URL after replacing $CLIENT_ID, $SCOPE, and $REDIRECT_URI
    https://accounts.spotify.com/authorize?response_type=code&client_id=$CLIENT_ID&scope=$SCOPE&redirect_uri=$REDIRECT_URI
  3. Note code from the URL you were redirected to
  4. Acquire your refresh token
    • Run the following CURL command
    curl -X POST https://accounts.spotify.com/api/token -d "client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&grant_type=authorization_code&code=$CODE&redirect_uri=$REDIRECT_URI"
    • Either replace or export the variables in your shell ($CILENT_ID, $CLIENT_SECRET, $CODE, and $REDIRECT_URI)
  5. Save refresh_token in your .env file as well as your client_id and client_secret.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment