From 403ab1cfa16fc4ad1955f39147bc8e2920710b5f Mon Sep 17 00:00:00 2001 From: Jesse Jarzynka Date: Wed, 8 Mar 2017 00:51:39 -0500 Subject: [PATCH] Add cache_path as an argument to prompt_for_user_token() --- spotipy/util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spotipy/util.py b/spotipy/util.py index 102c462..cb08b40 100644 --- a/spotipy/util.py +++ b/spotipy/util.py @@ -8,7 +8,7 @@ import spotipy import webbrowser def prompt_for_user_token(username, scope=None, client_id = None, - client_secret = None, redirect_uri = None): + client_secret = None, redirect_uri = None, cache_path = None): ''' prompts the user to login if necessary and returns the user token suitable for use with the spotipy.Spotify constructor @@ -20,6 +20,7 @@ def prompt_for_user_token(username, scope=None, client_id = None, - client_id - the client id of your app - client_secret - the client secret of your app - redirect_uri - the redirect URI of your app + - cache_path - path to location to save tokens ''' @@ -46,8 +47,9 @@ def prompt_for_user_token(username, scope=None, client_id = None, ''') raise spotipy.SpotifyException(550, -1, 'no credentials set') + cache_path = cache_path or ".cache-" + username sp_oauth = oauth2.SpotifyOAuth(client_id, client_secret, redirect_uri, - scope=scope, cache_path=".cache-" + username ) + scope=scope, cache_path=cache_path) # try to get a valid token for this user, from the cache, # if not in the cache, the create a new (this will send