Git Product home page Git Product logo

spotify-box's Introduction

spotify-box

Automatic update pinned gist to show your recent Spotify top tracks.

Don't forget to leave a โญ if you found this useful.


๐Ÿ“Œโœจ For more pinned-gist projects like this one, check out: https://github.com/matchai/awesome-pinned-gists

โœจ Inspiration

This code was heavily inspired by @jacc's music-box.

๐ŸŽ’ Prep Work

  1. Create a new public GitHub Gist (https://gist.github.com/)
  2. Create a token with the gist scope and copy it. (https://github.com/settings/tokens/new)
  3. Create a Spotify Application and get certified, detail steps you can see below.
Spotify Authorization Steps

1. Create new Spotify Application

Visit https://developer.spotify.com/dashboard/applications login and create a new Application

After create, you will get your Client ID & Client Secret.

Then click EDIT SETTINGS Button, add http://localhost:3000 to Redirect URIs

2. Get Authorization Code

Visit following URL after replace $CLIENT_ID to 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, the url like this: http://localhost:3000?code=$CODE

this $CODE is your Authorization Code, it will be used to generate access_token at next step.

3. Get Access Token

the last 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 run it at your terminal, you'll get your ${REFRESH_TOKEN}

the output may 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 not return refresh_token, back to step 2 and retry.

๐Ÿ–ฅ Project Setup

  1. Fork this repo
  2. Go to your fork's Settings > Environments > New environment and create an environment called "prod"
  3. Choose your "prod" environment and Add Secret for each environment secret (below)
  4. Enable Actions on your fork via the 'Actions' tab
  5. Enable the 'spotify-box' Workflow via the 'Actions' tab
  6. Kick off a workflow run of the 'spotify-box' Workflow via Actions > spotify-box > Run workflow

๐Ÿคซ Environment Secrets

  • GIST_ID: The ID portion from your gist url https://gist.github.com/<github username>/6d5f84419863089a167387da62dd7081.
  • GH_TOKEN: The GitHub token generated above.
  • SPOTIFY_CLIENT_ID: The Client ID you got from Spotify Developer Dashboard.
  • SPOTIFY_CLIENT_SECRET: The Client Secret you got from Spotify Developer Dashboard.
  • SPOTIFY_REFRESH_TOKEN: The Refresh Token you got from Spotify API.

๐Ÿ’ธ Donations

Feel free to use the GitHub Sponsor button to donate towards my work if you think this project is helpful. ๐Ÿค—

spotify-box's People

Contributors

cheshire137 avatar izayl avatar octokatherine avatar superleeyom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.