mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-26 16:15:51 +03:00
[GH-ISSUE #1002] AttributeError: 'dict' object has no attribute 'get_access_token' #597
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#597
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 @Zhiming77 on GitHub (Jul 12, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1002
I apologize, in advance, if this issue is inherently noob-ish. However, after solving my issue(s) relevant to the EOFError issue described here: https://github.com/spotipy-dev/spotipy/issues/632.
My bot is "successfully" hosted on Heroku, and I can use commands that don't access the Spotify API.
However, now when I try to access the API in any manner, for example,
playlists = sp.current_user_playlists(), I am getting the following error:[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/spotipy/client.py", line 338, in _put
[web.1]: return self._internal_call("PUT", url, payload, kwargs)
[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/spotipy/client.py", line 247, in _internal_call
[web.1]: headers = self._auth_headers()
[web.1]: ^^^^^^^^^^^^^^^^^^^^
[web.1]: File "/app/.heroku/python/lib/python3.11/site-packages/spotipy/client.py", line 238, in _auth_headers
[web.1]: token = self.auth_manager.get_access_token(as_dict=False)
[web.1]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[web.1]: AttributeError: 'dict' object has no attribute 'get_access_token'
The code I used to solve the issue described in the above link is as follows (and uses the MemoryCacheHandler):
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri, scope=scope, show_dialog=False, open_browser=False, cache_handler=MemoryCacheHandler(token_info=token_info) ).get_access_token(as_dict=True, check_cache=True))Why is self.auth_manager appearing as a dictionary herein (it would seem based on the spotipy code that it should not be appearing as a dictionary)?
Thank you in advance for any and all assistance!
@jeffp123 commented on GitHub (Jul 14, 2023):
I think the error is because you are passing
SpotifyOAuth(...).get_access_token(...)as theauth_managerparam.Try this instead? (reformatted for clarity and removed the
.get_access_token(as_dict=True, check_cache=True))@stephanebruckert commented on GitHub (Jul 9, 2024):
Looks like a solution was provided, closing