[GH-ISSUE #1199] Possible incorrect parameter for SpotifyPKCE.get_acces_token() #705

Closed
opened 2026-02-28 00:01:02 +03:00 by kerem · 3 comments
Owner

Originally created by @AnshulPatil29 on GitHub (May 15, 2025).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1199

Question

When reviewing the SpotifyPKCE implementation in spotipy.oauth2 oauth.py I see:

def get_access_token(self, code=None, check_cache=True):

There is no **kwargs to accept additional parameters, yet the core Spotify client client.py calls :

auth_manager.get_access_token(as_dict=False)

Should the PKCE manager’s get_access_token signature be updated (e.g. to include **kwargs or an as_dict parameter) to match the client’s expectations, or is there another intended mechanism to handle these extra arguments?
I had some errors when trying the code earlier but it was due to bad gateway in the traceback, but patching this in code caused the errors to go away which makes me uncertain about if this is handled currently or causes a bug elsewhere.

Originally created by @AnshulPatil29 on GitHub (May 15, 2025). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1199 **Question** When reviewing the `SpotifyPKCE` implementation in `spotipy.oauth2` [oauth.py](https://github.com/spotipy-dev/spotipy/tree/master/spotipy/oauth2.py) I see: ```python def get_access_token(self, code=None, check_cache=True): ``` There is no **kwargs to accept additional parameters, yet the core Spotify client [client.py](https://github.com/spotipy-dev/spotipy/tree/master/spotipy/client.py) calls : ```python auth_manager.get_access_token(as_dict=False) ``` Should the PKCE manager’s get_access_token signature be updated (e.g. to include **kwargs or an as_dict parameter) to match the client’s expectations, or is there another intended mechanism to handle these extra arguments? I had some errors when trying the code earlier but it was due to bad gateway in the traceback, but patching this in code caused the errors to go away which makes me uncertain about if this is handled currently or causes a bug elsewhere.
kerem 2026-02-28 00:01:02 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@dieser-niko commented on GitHub (May 15, 2025):

It seems that someone has already thought of this. However, I don't really approve of this method. There's actually a try-except block in the client.py file to catch a TypeError. Then it attempts to use the get_access_token function with no parameters.

@stephanebruckert how about removing the parameter as_dict from every function? It has been marked as deprecated for quite a long time.

<!-- gh-comment-id:2883151121 --> @dieser-niko commented on GitHub (May 15, 2025): It seems that someone has already thought of this. However, I don't really approve of this method. There's actually a try-except block in the client.py file to catch a `TypeError`. Then it attempts to use the `get_access_token` function with no parameters. @stephanebruckert how about removing the parameter `as_dict` from every function? It has been marked as deprecated for quite a long time.
Author
Owner

@stephanebruckert commented on GitHub (May 19, 2025):

@AnshulPatil29 without stack trace It's hard to tell where any error was raised. Can you please provide one?

some errors due to bad gateway in the traceback, patching this in code caused the errors to go away

If you "unpatch" it, is the error coming back?

@dieser-niko it looks like that was done in v3 already github.com/spotipy-dev/spotipy@c8e045891b

Removed the deprecated as_dict parameter from the get_access_token method of SpotifyOAuth and SpotifyPKCE.
https://github.com/spotipy-dev/spotipy/blob/v3/CHANGELOG.md#unreleased-300-alpha

<!-- gh-comment-id:2891998032 --> @stephanebruckert commented on GitHub (May 19, 2025): @AnshulPatil29 without stack trace It's hard to tell where any error was raised. Can you please provide one? > some errors due to bad gateway in the traceback, patching this in code caused the errors to go away If you "unpatch" it, is the error coming back? @dieser-niko it looks like that was done in v3 already https://github.com/spotipy-dev/spotipy/commit/c8e045891bb157afde75b5eb545aa8cb9d663d47 > Removed the deprecated as_dict parameter from the get_access_token method of SpotifyOAuth and SpotifyPKCE. > https://github.com/spotipy-dev/spotipy/blob/v3/CHANGELOG.md#unreleased-300-alpha
Author
Owner

@AnshulPatil29 commented on GitHub (Jun 11, 2025):

@stephanebruckert I am unsure where the error was raised exactly, but it ceased to exist upon clearing my pip cache and reinstalled. As far as I remember it was surely an error due to the as_dict parameter. Closing the issue now as it seems to have been addressed in a prior version. Thank you.

<!-- gh-comment-id:2962763900 --> @AnshulPatil29 commented on GitHub (Jun 11, 2025): @stephanebruckert I am unsure where the error was raised exactly, but it ceased to exist upon clearing my pip cache and reinstalled. As far as I remember it was surely an error due to the `as_dict` parameter. Closing the issue now as it seems to have been addressed in a prior version. Thank you.
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#705
No description provided.