mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 08:35:49 +03:00
[GH-ISSUE #1067] DeprecationWarning in get_access_token() when using SpotifyOAuth #628
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#628
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 @beeeegi on GitHub (Jan 2, 2024).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1067
Description of the bug
A DeprecationWarning is encountered when using
sp_oauth.get_access_token()with the following message:Code
Expected behavior
I expected to use
sp_oauth.get_access_token()without encountering aDeprecationWarning. The warning is suggesting a change in how the method is used.Output
Environment:
Additional context
I am encountering a warning message in my code despite its functionality being correct. The warning states:
While my code appears to work as expected, I want to confirm whether this warning is indicative of a potential issue in my usage of the spotipy library or if it is an expected behavior. I appreciate any guidance on whether any adjustments are needed in my code.
@Jack-Dane commented on GitHub (Jan 2, 2024):
@beeeegi, I don't support this project but I think I can provide some insight based on looking at the code.
It looks like based on the message, this function will just return the access token as a string instead of the dictionary in later versions of the package. The
kwargand warning provide a way for users to upgrade their Spotipy package without making a breaking change to existing code. You don't need to be concerned about this if you have no plans to upgrade the package.But it also looks like the
get_access_tokenfunction will automatically refresh the token if it has expired, so I don't see a need for you to implement this yourself. It looks like you could just use theaccess_token = sp_oauth.refresh_access_token(as_dict=False).github.com/spotipy-dev/spotipy@a14a28e10c/spotipy/oauth2.py (L523-L531)