Simplifying the implicit grant authorization flow for developers on Spotify's Web API
This Flask app helps streamline the tedious process of generating a Spotify access token through the Implicit Grant Flow.
To get the app running:
pip3 install -r requirements.txt
Configure your .env file with the following variables (a .env.example file can be found in the root of the repo):
SECRET_KEY
: This is required to use FlaskForms and can be generated with Python 3’s os
or secrets
module.
In a Python shell, simply copy the output of either of the following commands into your .env file:
# option 1 - generate key with os module
import os
os.urandom(32)
# option 2 - generate key with secrets module
import secrets
secrets.token_hex(16)
CLIENT_ID
: This is taken from an existing application in your Spotify developer dashboard (you will need to create one if you don’t already have one).RESPONSE_TYPE='token'
: The required parameter for obtaining authorization through the Implicit Grant Flow.REDIRECT_URI='http://localhost:5000/auth/callback/'
: This is the URL/route that is designed to work with this application. It must be white-listed in your application. scope
variable in the auth
view function.From there, you should be able to access the application via browser at http://localhost:5000/. Once you submit the form, it will redirect you to a login page asking to authorize the app to view your account. Once you’ve accepted, it will redirect you to the callback URL where you can copy the access token right off of the HTML page.
flask run