Closed Zhiming77 closed 4 months ago
I think the error is because you are passing SpotifyOAuth(...).get_access_token(...)
as the auth_manager
param.
Try this instead? (reformatted for clarity and removed the .get_access_token(as_dict=True, check_cache=True)
)
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),
)
)
Looks like a solution was provided, closing
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: 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: 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)
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!