I cannot figure out how to configure Spotify’s APIs to work for any amount of time. The tokens always die and I cannot figure out how to refresh them. I want to be able to search Spotify podcasts from our app.
I’ve seen forum topic, “Spotify Refresh Token” and I don’t understand how it relates to what I’ve done. Here’s my configuration:
Because this is normal in API Connector. Bubble doesn’t refresh the API connector. But for your user, if this is the case, do you use differents Social network login? Ex: A user can create an account using Google and you try to authenticate this user to Spotify too?
Sorry, just checked and I think it will not work. Client credentials are fot that normally, but Spotify doesn’t allow access to user reccources.
You will need to create your own process becauseBubble will only set the user agent oAuth2 for the current authenticated agent. If you want to use theses credentials while another user is logged in, it won’t work.
When successfully logged into Spotify you’ll be granted with an Access Token (long code starting with “B”) that will expire in 3600 seconds and a Refreshable Token (starting with “A”) that you must store securely in your database and “refresh” (if expired) every time you communicate with their API.
You can find some examples in their API documentation.
Thanks! I have hope again!
I still don’t know how this translates into configuring Bubble’s API Connector to make this work. Can I use Authentication: OAuth2 User-Agent Flow as I have above? If so, what do I need to configure differently? If not, which authentication type do I choose and how would that be configured?
Hey @TipLister , for my app like you mentioned, I will only need my token since the user will just be accessing public information from the Spotify Search API, and I’m still not sure where and what to call to to request a refresh token every hour. heres my setup below, I am just plugging in the new bearer code every hour that I request manually from the Spotify developer console. I watched that video and I’m not sure how to translate it to Spotify.
Thank you @TipLister ! I worked through those videos and got everything working.
I know this is a long shot but my goal is for the user to not have to log into Spotify, but to piggyback off my authorization/account. I was wondering if you think it is possible for the backend of bubble to automatically refresh my token without each user having to do anything at all, since no user data is needed for my app, just search results, which can be accessed through my one account. Would there be a way for it to automatically log me in and do the requests i.e. “Do every 3600 seconds” workflow behind the scenes? Or is it unavoidable because one of the steps in the process requires someone to go to an external address.
Otherwise I will be up every hour to refresh the authorization manually lol. Thanks in advance for any tips that you may have!
so add a new datatype called token with the fields until when it expires [a date], the access and the refresh token.
in this add just one row manually.
then on page load check if we are past expiry date
if yes schedule an api workflow
this api workflow is in backend and uses refresh token to create new access token.
as it is on page load it works for every user.
[if you had 1000 users you would have 1000 rows but here 1 is fine]