mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #507] spotipy.oauth2.SpotifyOauthError: You must either set a cache_path or a username #304
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#304
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 @Joshua-C-Clark on GitHub (Jun 1, 2020).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/507
I am trying to set up a web app and am first following your example app.py. I am running in to the following issues:
1.) SpotifyOauthError message for not passing a redirect_uri.
This was corrected by passing a url that has also been added to the Spotify Developer Dashboard.
auth_manager = spotipy.oauth2.SpotifyOAuth()
BECOMES
auth_manager = spotipy.oauth2.SpotifyOAuth(redirect_uri='http://localhost:5000/')
At this point I am able to open the app in my localhost and click the generated "Sign In" hyperlink. It loads the Spotify Authorize page, but when I click the "Agree" button I receive the following error:
spotipy.oauth2.SpotifyOauthError
spotipy.oauth2.SpotifyOauthError: You must either set a cache_path or a username.
I don't have a given user's username for the purpose of this app, since the user is supposed to be authenticating with Spotify and granting me scopes. Any examples on stackoverflow or your app.py are not passing a username.
@Joshua-C-Clark commented on GitHub (Jun 2, 2020):
Issue resolved by passing a cache file destination path:
sp_oauth = spotipy.oauth2.SpotifyOAuth(client_id=CLIENT_ID, client_secret=CLIENT_SECRET ,redirect_uri=REDIRECT_URI,scope=SCOPE, show_dialog=True, cache_path=CACHE)Working through how to structure the caches files/folder for multiple users to be stored, as well as how to remove/delete a cache for a given user to allow for login/log off functionality to switch users logging in to the app.
@stephanebruckert commented on GitHub (Jun 3, 2020):
See if this example can help https://github.com/plamere/spotipy/blob/master/examples/app.py, it allows multiple users to sign in at the same time. Currently it doesn't clear the tokens in the back-end, but that's something that can be improved
@MikeiLL commented on GitHub (Jul 6, 2020):
I don't know that this issue is resolved. When, in the App example, we instantiate
spotipy.oauth2.SpotifyOAuthwithout specifying either ausernameorcache_path, the example returns an error, which you can see on line 274,elif not self.cache_path and not self.usernameit raisesSpotifyOauthError, "You must either set a cache_path or a username.")Personally, I am storing the credentials in a separate file,
credentials.py, which I import and then instantiate like this:This is a super-helpful demo, by the way. I think we can make it even more so.
@stephanebruckert commented on GitHub (Jul 6, 2020):
I personally can't reproduce it but I've reopened the issue
@MikeiLL commented on GitHub (Jul 6, 2020):
Thanks. I'm having another problem, which is that current_user_playing_track and currently_playing, called without arguments:
raise a "Permissions missing" exception:
Looking at the _internal_call that
_getpoints to but I'm not sure if I should be sending something toargs,payload, or**kwargs.I expect it's my own ignorance, rather than a bug. Would you like me to create a new issue? Run to Stack Overflow?
Thanks, man.
@stephanebruckert commented on GitHub (Jul 6, 2020):
@MikeiLL I've never seen that one, please create a new issue with your full code
@MikeiLL commented on GitHub (Jul 6, 2020):
Done. Thank you.