spotify-webplayer-token

command module
v0.0.0-...-77f98b8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 3 Imported by: 0

README

spotify-webplayer-token

Helper to retrieve a webplayer Spotify token that is valid for 1 year.

Inspired from https://github.com/enriquegh/spotify-webplayer-token and adapted to golang.

To obtain the cookies (valid for 1 year):

  • Open a new Incognito window in Chrome (or another browser) at https://accounts.spotify.com/en/login?continue=https:%2F%2Fopen.spotify.com%2F
  • Open Developer Tools in your browser (might require developer menu to be enabled in some browsers)
  • In the Network tab, enable "Preserve log"
  • Login to Spotify.
  • In the Network tab, search/Filter for password
  • Under cookies for the request save the values for sp_dc and sp_key.
  • Close the window without logging out (Otherwise the cookies are made invalid).

To obtain a Spotify token:

Programmatically
  1. Store sp_dc and sp_key respectively as environment variables SPOTIFY_DC and SPOTIFY_KEY,

  2. Do:

    import (
        "github.com/mirrorfm/spotify-webplayer-token/app"
    )
    
    func main() {
        token, err := app.GetAccessTokenFromEnv()
        // use token.AccessToken
    }
    
From the command line
  1. In the current repo, create env.json such as:

    {
        "SPOTIFY_DC": "AQAJJvY80mY--nNZ_vWVMyWrvrSse...",
        "SPOTIFY_KEY": "478fafec-ed..."
    }
    
  2. Run:

    make setup && make run
    

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL