mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 08:35:49 +03:00
[GH-ISSUE #551] Requesting access token with authorization code #332
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#332
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 @sheptang on GitHub (Jul 29, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/551
I'm aware that get_access_token() is designed to return only the "access_token" value from the general token dictionary.
But unfortunately, some of us would still need to retrieve full dictionary version of the token, by passing the authorization code value.
Because, for my implementation, the dictionary token with all of its other data (such as "refresh_token", "expiry", ...) is needed.
I tried to find any other way to get this data through Spotipy, but the only useful method I found was get_access_token(), and the warning message for as_dict deprecation affects my code flow.
I also tried to work around it, trying to use _request_access_token(), where get_access_token() retrieves its initial data from, but of course, I was unsuccessful since the library wasn't designed like that.
If I'm missing anything or making mistakes, I'm certainly open for feedback or any suggestions. Thanks!
@stephanebruckert commented on GitHub (Jul 29, 2020):
Try
auth_manager.get_cached_token()@sheptang commented on GitHub (Jul 29, 2020):
Thanks for lightning fast reply!
I've already tried to use it that way, but the problem is that I need to retrieve the token by passing the auth code in the very beginning of token request. That's why I can't access any cached token before requesting for one.
If I wasn't fairly new to Python, I'd try creating a new method from scratch or a workaround to suit my needs.
@stephanebruckert commented on GitHub (Jul 29, 2020):
Have a look at these lines in this example:
github.com/plamere/spotipy@f136442c2d/examples/app.py (L41..L45)First we use
get_access_token(code)without caring about the result, and then you can usetoken_info = get_cached_token()to retrieve the full json@sheptang commented on GitHub (Jul 29, 2020):
Now it makes perfect sense, looks like I've missed it. My bad.
Thank you!