a simple python script that allows you to control playback of spotify connect without the need of a local server
Spotify Documentation: https://developer.spotify.com/documentation/web-api/guides/using-connect-web-api/
Follow these instructions to create a spotify app
https://developer.spotify.com/documentation/general/guides/app-settings/
The name and description are up to you.
Add the whitelisted redirect url 'http://Localhost'
Then copy and paste an Client_id and Client_secret of the app into the constants.py file
From there you can just run
python3 spotify.py
to authorize it. Copy and paste the url printed from the script into your browser and click ok to authorize. You will then be redirected to a url that looks like http://localhost?code=XXXXXXXXXX ect
Copy and paste that url back into the terminal to complete authorization.
Now you can just call the provided script methods to play, pause, set the volume, get devices and playlists.
This authorization flow works for the rest of the api as well so feel free to browse around https://developer.spotify.com/documentation/web-api/reference/ to see what other api endpoints you can add to the script.
This script will also handle the refresh token for you. Every time you call a command it will check if the current token is expired and if it is, it automagicly use the refresh token and gets a valid access_token before the command is called