mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #789] Use Spotipy OAuth authorization from inside a Docker container #487
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#487
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 @jkulak on GitHub (Mar 8, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/789
I am trying to authenticate, to get my followed artists.
My authentication code. I also tried with
SpotifyOAuth:My code is being run inside a Docker
FROM python:3.10.2-alpine3.15container.Browser is not being opened (I guess it's ok, it's trying to open it on a container level not on my OS/host level), but when I open the given URL in the browser i.e.:
https://accounts.spotify.com/authorize?client_id=4ec8[...]1bc0b&response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A3002&code_challenge_method=S256&code_challenge=y80Z9Y7o5n4nq6BgnKr2b0WBrT_KpVQyw9AjDl051jA&scope=user-follow-readIt seems like the http server from Spotipy is not running and not waiting for the
/?code=...parameter. I think all the proper ports are exposed from Docker correctly and forwarded when creating containers-p 3002:3002. Spotify Application has it's Redirect URI configured properly (with the port etc.).Still, I'm getting
in the browser, and Spotipy is waiting for the code.
Using
open_browser=Falseand manually pasting the url with code works - but that's not what I'm looking for.@jkulak commented on GitHub (Mar 9, 2022):
I solved it by changing below line:
github.com/plamere/spotipy@9a627e88f4/spotipy/oauth2.py (L1303)to:
server = HTTPServer(("0.0.0.0", port), handler)(meaning, Spotipy is listening on any IP address).I would suggest a solution either to read that value from ENV ie.
SPOTIPY_SERVER_IPwhich could default to127.0.0.1no to break current functionality.127.0.0.0.1will not work inside a Docker container.@Dielee commented on GitHub (Jul 7, 2022):
@jkulak how do you set the port for Spotipy http Server ?
@jkulak commented on GitHub (Aug 4, 2022):
Hi @Dielee. It's being read from
SPOTIPY_REDIRECT_URIenv variable.You can see it here in the code:
github.com/plamere/spotipy@9a627e88f4/spotipy/oauth2.py (L478)Port is a part of URI, so I just set it to
SPOTIPY_REDIRECT_URI=http://127.0.0.1:8083.