mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #1198] Calls with local server is frozen #702
Labels
No labels
api-bug
bug
dependencies
documentation
duplicate
enhancement
external-ide
headless-mode
implicit-grant-flow
invalid
missing-endpoint
pr-welcome
private-api
pull-request
question
spotipy3
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotipy#702
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 @GuyKh on GitHub (May 14, 2025).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1198
Describe the bug
A clear and concise description of what the bug is.
Some context - I'm running raspotify service and try to trigger playing a track through
spotipy.Have redirect url configured in Spotipy settings.
Also - up until changes in their API - it used to work with redirect url =
http://192.168.1.100:8080Your code
Expected behavior
return a list of devices.
Output
Logs are stuck after
sp initialized.cmd+cgives this stack trace:Environment:
Additional context
This is unrelated to passed scopes etc.
@GuyKh commented on GitHub (May 14, 2025):
An additional observation;
When running
nmap 127.0.0.1 -p 8000-9000while in this stuck state.The app crashes with:
@GuyKh commented on GitHub (May 14, 2025):
As this is a server-to-server flow, I've also considered using
SpotifyClientCredentialsCode:
Output:
@dieser-niko commented on GitHub (May 14, 2025):
I'll start with the
SpotifyClientCredentials, since it's easier to explain why it's not working.When you use that auth flow, your app doesn't bind to a user, meaning you won't have access to a player.
Regarding the other issue, it looks like the server is waiting for a callback. Could you try to pass
open_browser=FalsetoSpotifyOAuthas shown in headless.py? You should then get a link where you can log in with your account.Alternatively you could share your authorization flow.
@GuyKh commented on GitHub (May 14, 2025):
@dieser-niko the purpose of this is a service to run (headless indeed) - and send
Play media Xto a certain device.Is the
open_browser=falserelevant in this case?@dieser-niko commented on GitHub (May 14, 2025):
Yes, spotipy opens the browser with the authentication url. If there's no browser or you only have a CLI, this step will fail.
If you set
open_browsertoFalse, then the auth url will be printed instead.@dieser-niko commented on GitHub (May 14, 2025):
Alternatively you could implement your own flow, another example would be an implementation with FastAPI:
https://github.com/dieser-niko/spotipy-fastapi-oauth
But I think the headless example might be the best option for you.
@GuyKh commented on GitHub (May 14, 2025):
@dieser-niko any idea about token refresh? The intention is for it to run on a raspberrypi with RF card reader where every card is a different song.
The thing is that there could be a long time (days) between card swipes. So I cant have a re-login flow once in a while.
Any idea about that?
@dieser-niko commented on GitHub (May 14, 2025):
Usually, you don't need to re-authenticate that often, if at all. But to be honest, I have no idea how long a refresh token lasts. The only information I could find on it is here: https://github.com/spotify/web-api/issues/911#issuecomment-581104335
@GuyKh commented on GitHub (May 14, 2025):
Looks like this works flawlessly with
open_browser=FalseThanks