spotipie.auth.utils

Functions

get_user_authorization(session[, app_name, …])

Asks the user to authorize the authorize your app.

prompt_for_user_authorization(session)

Useful for command-line apps, when you don’t want to use get_user_authorization().

Reference

spotipie.auth.utils.get_user_authorization(session, app_name=None, port=1234, timeout=120)[source]

Asks the user to authorize the authorize your app. The authorization flow depends on the type of session to pass. As a side effect, the obtained token is stored in the session.

This function launches a flask app listening to http://localhost:{port}/callback in a new thread, which once the authorization is completed, sends the received token to the main thread through a messaging queue; in this way, this function does not require the user to manually copy and paste the callback URL into your app.

IMPORTANT: to use this function

  • you need to install optional dependencies through: pip install spotipie[auth-app]

  • you need to whitelist http://localhost:{port}/callback in your app callback URLs.

Parameters
Return type

OAuth2Token

Returns

OAuth2Token

See Also:

spotipie.auth.utils.prompt_for_user_authorization(session)[source]

Useful for command-line apps, when you don’t want to use get_user_authorization(). Asks the user to authorize your app through the terminal. It requires the user to manually copy and paste the callback URL into the terminal.

Return type

OAuth2Token