Spotify Readme Widget
Dynamically generated Spotify widgets for GitHub readme!
Table of Contents
✨ Now Playing Card
Copy-paste this in your GitHub readme, and that's it!
Change <HEROKU_INSTANCE_NAME>
with the name of your personal instance.
<img src="https://<HEROKU_INSTANCE_NAME>.herokuapp.com/api/spotify/now" />
Themes
You can customize the look of the card using pre-built themes.
Add ?theme=THEME_NAME
like so:
<img src="https://<HEROKU_INSTANCE_NAME>.herokuapp.com/api/spotify/now?theme=vue-dark" />
📤 Deploy
To make this app work it is necessary to provide data that changes from user to user, thus making it mandatory to create your own instance.
Of course, everything will be completely free, thanks to Heroku, but it will take a few minutes to set up.
Spotify Setup
Spotify
- Create a Spotify Application.
- Take note of
Client ID
andClient Secret
. - Click on Edit Settings.
- Add
http://localhost/callback/
on Redirect URIs section.
Refresh Token
- Navigate to the following URL:
- Remember to replace
{SPOTIFY_CLIENT_ID}
with theClient ID
of your newly created application.
https://accounts.spotify.com/authorize?client_id={SPOTIFY_CLIENT_ID}&response_type=code&scope=user-read-currently-playing,user-read-recently-played&redirect_uri=http://localhost/callback/
- Remember to replace
- Log in, take note of the
{CODE}
portion fromhttp://localhost/callback/?code={CODE}
. - Combine in a string
{SPOTIFY_CLIENT_ID}:{SPOTIFY_CLIENT_SECRET}
and encode into Base64.- WARNING:
{SPOTIFY_CLIENT_ID}
and{SPOTIFY_CLIENT_SECRET}
are actually separated by:
.
- WARNING:
- Run from Git Bash the following curl command:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic {BASE64}" -d "grant_type=authorization_code&redirect_uri=http://localhost/callback/&code={CODE}" https://accounts.spotify.com/api/token
- Take note of the Refresh Token.
Heroku Setup
Instructions for deploying to Heroku
- Sign in to Heroku or create a new account at https://signup.heroku.com/
- Press the "Deploy to Heroku" button below:
- Click "Deploy App" on the page that comes up, then wait for the app deploy.
- Once the app is deployed, click "Manage App" to go to the dashboard.
- Go to the "Settings" tab and click "Reveal Config Vars".
- Add your personal data obtained from Spotify:
SPOTIFY_CLIENT_ID
: Your Spotify Application Client IDSPOTIFY_CLIENT_SECRET
: Your Spotify Application Client SecretSPOTIFY_REFRESH_TOKEN
: Your Spotify Refresh Token.
- Check the Domains section to get the URL of your instance.
Made with Javascript, EJS and ❤️