mirror of
https://github.com/kokarare1212/librespot-python.git
synced 2026-04-25 08:35:49 +03:00
[GH-ISSUE #195] [REQUEST] Create session using user's token #34
Labels
No labels
bug
dependencies
duplicate
enhancement
invalid
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot-python-kokarare1212#34
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @staniel359 on GitHub (May 21, 2023).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/195
Is your feature request related to a problem? Please describe.
I'm running your library on a server for multiple users.
Right now I'm using my own Spotify credentials for all users.
When a user decides to connect their account, instead of storing their credentials I'd like to store their access token (for security reasons) and use it to create each user's session.
Describe the solution you'd like
Session.Builder().token(<USER_TOKEN>)@kokarare1212 commented on GitHub (May 21, 2023):
Perhaps this should work.
@staniel359 commented on GitHub (May 21, 2023):
@kokarare1212 But what if I don't want to use any users' emails or passwords?
Is it possible to login user via their token?
@kokarare1212 commented on GitHub (May 21, 2023):
It is necessary for the first login, but from the next time onward, such a thing can be done by obtaining something like a token in session.stored and passing it as an argument to Session.Builder.stored, as in the above code.
@staniel359 commented on GitHub (May 21, 2023):
@kokarare1212 Okay, thanks.
@prime-rue commented on GitHub (Jun 8, 2025):
I can't get it to work. Could you please explain to me how I could use the following credentials to create a session?
{'access_token': 'BQAHHtai9r6xIHb2SPVYUCMG7XCoDbzhZGX0Qz-XXXXXXXXXXXXXXXXXX-uYj6g41R_PFQGMru5b60ZVkPiW83Dutw8VVRd35BAEJB0mRfBaeFU8aEhiDxF8Toy5gVI7eoaC_6Cn36So
-Ztx6me1SBMe_BMu6i_FBhUfJyTWTyjINX5whrTnwgqRcDlUu6ps8tl0iv_uwYA1FjRXjrnZmLXXXXXXXXXXXXXXXX',
'token_type': 'Bearer',
'expires_in': 3600,
'refresh_token': 'AQBLAs-XXXXXXXXXXXXXXXXXX-BMfRqEqZaAtZLzaRAmGny1jnseoOSOD_tDDB5GbwERZDYvqTMz26HMmDA32Rpw3UmEz3lhXk7z3NUAMjsxkr_yNLgTb273HrDdrxc3NwI',
'scope': 'user-library-read',
'expires_at': 1748377911}
I tried:
session = Session.Builder()
session.login_credentials = Authentication.LoginCredentials(
typ=Authentication.AUTHENTICATION_SPOTIFY_TOKEN,
username=SPOTIPY_CLIENT_USERNAME, # The username I specified for receiving the credentials.
auth_data=b'access_token'
)
session = session.create()
I obtained the credentials using spotipy.
@kokarare1212 commented on GitHub (Jun 8, 2025):
@prime-rue You probably cannot use Web API tokens.
@prime-rue commented on GitHub (Jun 8, 2025):
Okay, thank you for your quick reply. Are there any other methods beside zeroconf, which I can use to login individual users?
@kokarare1212 commented on GitHub (Jun 8, 2025):
Currently, you can log in using Zeroconf or by obtaining an authentication file using another librespot, but the latter cannot be supported here.