mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #719] Authenticating Spotipy for a single dedicated account #430
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#430
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 @lucs100 on GitHub (Aug 21, 2021).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/719
I apologize in advance because I'm pretty sure this has been sorta asked before but I was having trouble getting started. At the moment my use case for Spotipy only involves interacting with a single dedicated account that I own, and essentially allows (only a few friends can interface with it so I won't be too overrun with requests or anything) multiple people to collaborate on a playlist in a roundabout way (I'm aware that this is a feature in Spotify already, but I wanted to create my own implementation of it). Therefore, I only need to authenticate access to that user account 'permanently' (I'm vaguely aware of tokens expiring after an hour, needing to be refreshed, etc., I should be able to deal with that later).
However, it seems like I'll have to go through OAuth for this, or generate a token in my program to use later. Having only surface level Python experience, I am thoroughly confused on how I'd go about doing this.
My current code to try and authenticate my account, which is admittedly copy-pasted boilerplate, looks like this:
I know this is all-around horrible practice when asking for programming assistance, but I am just absolutely lost on where to go from here. I assume once my
spinstance is 'authenticated' I'll be able to use it to make requests/posts, but I can't seem to figure out how to either use OAuth to authenticate my dedicated account for use, or how to generate a token through Spotipy. The relevant documentation is rather confusing for me as well - I assume I'd have to use authorization code flow, but the implementation doesn't seem to make much sense to me.Apologies again for taking the lazier way out, but a starting point would be massively appreciated. 😅
@stephanebruckert commented on GitHub (Aug 21, 2021):
Since you plan to do user actions, you will need
SpotifyOAuthinstead ofSpotifyClientCredentials. Please check the 2 examples in the README to see the difference https://github.com/plamere/spotipy#quick-startYou don't have to worry about that, spotipy takes care of it.
Once you've got the second example in the README working (with the help of Getting Started), the rest is not difficult: you will want to replace
sp.current_user_saved_tracks()by any other method from the doc that is useful to you.The docs are probably not perfect, so please feel free to bring improvements while you are going through it!
@lucs100 commented on GitHub (Aug 21, 2021):
Seems to be working perfectly. My test method went through once I sorted everything out. Thanks so much for the pointer in the right direction, I'll close the issue now.
@stephanebruckert commented on GitHub (Aug 21, 2021):
'mazing!