This project is based on spotify-box, it uses Ruby with minor modifications instead of JavaScript.
- Create a new public GitHub Gist (https://gist.github.com/).
- Create a token with the
gist
scope and copy it. (https://github.com/settings/tokens/new). - Create a Spotify Application, detail steps you can see below.
Get Spotify Refresh Token
-
Visit https://developer.spotify.com/dashboard/applications and create a new application, after creating your app, you will get your Client ID & Client Secret.
-
Then click
EDIT SETTINGS
Button, addhttp://localhost:3000
to Redirect URIs.
- Visit following URL after replacing
$CLIENT_ID
with yours.
https://accounts.spotify.com/en/authorize?client_id=$CLIENT_ID&response_type=code&redirect_uri=http:%2F%2Flocalhost:3000&scope=user-read-currently-playing%20user-top-read
- Agree to this application to access your info, after that your will be redirect to a new page.
- URL:
http://localhost:3000?code=$CODE
, the$CODE
is your Authorization Code, it will be used to generate access_token at next step.
- Use the
$CLIENT_ID
and$CLIENT_SECRET
from step 1,$CODE
from step 2 to replace the shell command below.
curl -d client_id=$CLIENT_ID -d client_secret=$CLIENT_SECRET -d grant_type=authorization_code -d code=$CODE -d redirect_uri=http://localhost:3000 https://accounts.spotify.com/api/token
- After that run it at your terminal, you'll get your
$REFRESH_TOKEN
. The output will be like this:
{
"access_token": "BQBi-jz.....yCVzcl",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "AQCBvdy70gtKvnrVIxe...",
"scope": "user-read-currently-playing user-top-read"
}
- If the response didn't return refresh_token, back to step 2 and retry.
If you are going to use it with GitHub Actions please do not skip Environment Variables section.
- See .env.example.
This repository is licensed under the Apache License 2.0.