Closed Basti110 closed 4 months ago
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 token
and a refresh 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.
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
@Basti110 is your issue resolved or do you still need help and/or other solutions to your problem?
Closing as there is no activity or reply from the author.
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