[GH-ISSUE #1081] How can I authorize my client with just a callback code? #642

Closed
opened 2026-02-28 00:00:28 +03:00 by kerem · 1 comment
Owner

Originally created by @Le0X8 on GitHub (Mar 30, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1081

I am new to spotipy and wonder why I cannot simply login with just a callback code from the Spotify authorization process like it's being implemented in the PHP Spotify API wrapper by jwilsson.

Is there really no good way to authenticate normally?

I created a simple function to fetch the code:

def login():
  global client_id, user, code
  scope = 'user-read-currently-playing%20playlist-read-private%20playlist-read-collaborative%20user-follow-read%20user-top-read%20user-read-recently-played%20user-library-read%20user-library-read'
  webbrowser.open('https://accounts.spotify.com/authorize?response_type=code&' + scope + '&redirect_uri=http%3A%2F%2Flocalhost%3A45000%2F&client_id=' + client_id)
  code = authserver.getCode()

And now I'm looking for a method like spotipy.Spotify(client_id=client_id, client_secret=client_secret, callback_code=code), but I cannot find it, and also cannot find something else than the "using an auth manager to open the browser again and pointing to an URL that does not exist" method which really sucks.

The "using an auth manager to open the browser again and pointing to an URL that does not exist" method:

spotipy.Spotify(auth_manager=spotipy.SpotifyOAuth(client_id=client_id, client_secret=client_secret, redirect_uri='http://localhost:45000/', scope='user-read-currently-playing,playlist-read-private,playlist-read-collaborative,user-follow-read,user-top-read,user-read-recently-played,user-library-read,user-library-read'))
Originally created by @Le0X8 on GitHub (Mar 30, 2024). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1081 I am new to spotipy and wonder why I cannot simply login with just a callback code from the Spotify authorization process like it's being implemented in the PHP Spotify API wrapper by jwilsson. Is there really no good way to authenticate normally? I created a simple function to fetch the code: ```py def login(): global client_id, user, code scope = 'user-read-currently-playing%20playlist-read-private%20playlist-read-collaborative%20user-follow-read%20user-top-read%20user-read-recently-played%20user-library-read%20user-library-read' webbrowser.open('https://accounts.spotify.com/authorize?response_type=code&' + scope + '&redirect_uri=http%3A%2F%2Flocalhost%3A45000%2F&client_id=' + client_id) code = authserver.getCode() ``` And now I'm looking for a method like `spotipy.Spotify(client_id=client_id, client_secret=client_secret, callback_code=code)`, but I cannot find it, and also cannot find something else than the "using an auth manager to open the browser again and pointing to an URL that does not exist" method which really sucks. The "using an auth manager to open the browser again and pointing to an URL that does not exist" method: ```py spotipy.Spotify(auth_manager=spotipy.SpotifyOAuth(client_id=client_id, client_secret=client_secret, redirect_uri='http://localhost:45000/', scope='user-read-currently-playing,playlist-read-private,playlist-read-collaborative,user-follow-read,user-top-read,user-read-recently-played,user-library-read,user-library-read')) ```
kerem 2026-02-28 00:00:28 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@Le0X8 commented on GitHub (Mar 30, 2024):

This isn't even required for my purposes, so I can just use the built-in function.

The authserver I implemented is completely pointless then.

<!-- gh-comment-id:2028477735 --> @Le0X8 commented on GitHub (Mar 30, 2024): This isn't even required for my purposes, so I can just use the built-in function. The authserver I implemented is completely pointless then.
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#642
No description provided.