mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-04-27 00:25:54 +03:00
[GH-ISSUE #1031] User Authorization in Cloud Functions #616
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#616
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 @Basti110 on GitHub (Oct 5, 2023).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/1031
Hey,
is it somehow possible to authorize a cloud function to add new songs to my private playlist, at any time without user interaction? I can not use bowser login with redirection urls in the cloud or at least I do not know how to use them there. Is there a direct way to log into my Spotify account via the API? The client credentials flow works in the cloud, but I can't use it to access my account. It always says "This request requires user authentication".
Thank you!
Sebastian
@deanja commented on GitHub (Oct 29, 2023):
I'm trying to get my head around this too.
First I can confirm that Spotify user data can't be accessed with Client Credentials flow. Instead I used the Authorization Code flow - https://developer.spotify.com/documentation/web-api/tutorials/code-flow.
For your cloud function solution it might work like this:
access tokenand arefresh token, which can be used unattended, but will expire.That oAuth2 refresh token should be valid at least until redeemed for an access token, and possibly indefinitely until the user revokes access by your app in Spotify.
You could write a web app or similar to do step 1, to guide user through the Spotify authentication and save the tokens where your cloud function can access them.
@Nico-VC commented on GitHub (May 1, 2024):
Yes. The key is running the authorization code flow once to get the .cache file for that user and have that accessible to read everytime your function runs.
See https://stackoverflow.com/questions/48883731/refresh-token-spotipy
@dieser-niko commented on GitHub (May 6, 2024):
@Basti110 is your issue resolved or do you still need help and/or other solutions to your problem?
@dieser-niko commented on GitHub (May 26, 2024):
Closing as there is no activity or reply from the author.