Refresh token with Client User Agent Flow

Hello everyone,

I’m a bit lost with the refresh token issue that doesn’t work using the “Client User Agent Flow” in the API Connector. Here is my case:

  1. My users create an account on my Bubble app.
  2. Then, they need to authorize the connection to the external API service using OAuth 2 (Social Network Button), which responds with a code.
  3. The API sends a request to exchange the code for a token.

At this point, everything works perfectly, and the user data available in the external API are instantly synchronized in my Bubble app.

The problem is that every hour, I need to continuously synchronize my users’ data with the external API from the backend. And then, I realize each time that the token has expired and the API Connector does not handle the token refresh.

So, I thought about creating the refresh token process myself in the backend, but with so many users, it quickly becomes complicated and overloads the server capacity.

I would like to confirm with you if Bubble indeed takes care of refreshing the token upon expiration?

I would have liked to use the “Client Credentials Flow,” but the problem is that the scope is public, and the information shared is very limited. Therefore, I must use all the scopes to access all the endpoints and fetch the information.

I also saw “Custom Token.” Could that be a solution?

Thank you for your help.

What I understand is that you currently process to the auth manually (you have a link to authorize endpoint, you get a code, use API Connector to exchange it for acess token and store it in DB).

You need to complete this WF by also saving the refresh token, the expiration date and add API call to the refresh token endpoint (that should be the same as token, but with a different type). In your WF, when you need to use this API, you need to first check if the token is expired and if yes, request a new access token using the call to token endpoint and again, save it to DB with the nex expiration.