[GH-ISSUE #451] util.prompt_for_user_token only returns token for on user #267

Closed
opened 2026-02-27 23:21:42 +03:00 by kerem · 3 comments
Owner

Originally created by @coffeemakingtoaster on GitHub (Mar 11, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/451

When calling util.prompt_for_user_token(username) I always get the authentication token for one user (no matter what username I pass to the function). I saw that clearing the cache was marked as "enhancement" but I was wondering if there are any workarounds for now.
Thanks in advance :D

Originally created by @coffeemakingtoaster on GitHub (Mar 11, 2020). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/451 When calling util.prompt_for_user_token(username) I always get the authentication token for one user (no matter what username I pass to the function). I saw that clearing the cache was marked as "enhancement" but I was wondering if there are any workarounds for now. Thanks in advance :D
kerem closed this issue 2026-02-27 23:21:42 +03:00
Author
Owner

@stephanebruckert commented on GitHub (Mar 11, 2020):

It might find and use your existing token. To sign in using another user, can you try

util.prompt_for_user_token(username, show_dialog=True)
<!-- gh-comment-id:597794047 --> @stephanebruckert commented on GitHub (Mar 11, 2020): It might find and use your existing token. To sign in using another user, can you try util.prompt_for_user_token(username, show_dialog=True)
Author
Owner

@coffeemakingtoaster commented on GitHub (Mar 11, 2020):

Still returns token for a different user. Printing me() returns a different account than the one passed to prompt_for_user_token().
I am unsure if show_dialog=True should enable terminal output, because it doesn´t.

My code:

`import os
import spotipy.util as util
import spotipy

os.environ["SPOTIPY_CLIENT_ID"] = my client id
os.environ["SPOTIPY_CLIENT_SECRET"] = my secret
os.environ["SPOTIPY_REDIRECT_URI"] = "https://google.com"

username = a username
scope = "user-read-private user-read-email user-read-playback-state user-modify-playback-state"

my_token = util.prompt_for_user_token(username,scope=scope,show_dialog=True)

print(spotipy.Spotify(auth=my_token).me())`

<!-- gh-comment-id:597810710 --> @coffeemakingtoaster commented on GitHub (Mar 11, 2020): Still returns token for a different user. Printing me() returns a different account than the one passed to prompt_for_user_token(). I am unsure if show_dialog=True should enable terminal output, because it doesn´t. My code: `import os import spotipy.util as util import spotipy os.environ["SPOTIPY_CLIENT_ID"] = my client id os.environ["SPOTIPY_CLIENT_SECRET"] = my secret os.environ["SPOTIPY_REDIRECT_URI"] = "https://google.com" username = a username scope = "user-read-private user-read-email user-read-playback-state user-modify-playback-state" my_token = util.prompt_for_user_token(username,scope=scope,show_dialog=True) print(spotipy.Spotify(auth=my_token).me())`
Author
Owner

@coffeemakingtoaster commented on GitHub (Mar 11, 2020):

Found the solution. Logging out of any spotify account in my browser solved the issue as it seems a token for the currently logged in account was prompted.
Thank you for your help and quick response!

<!-- gh-comment-id:597814683 --> @coffeemakingtoaster commented on GitHub (Mar 11, 2020): Found the solution. Logging out of any spotify account in my browser solved the issue as it seems a token for the currently logged in account was prompted. Thank you for your help and quick response!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#267
No description provided.