Automating Bearer Token Refresh in Retool REST API Resource

  • Goal: I want to automatically refresh the bearer token in the Retool REST API resource when the current bearer token expires.

  • Steps taken: I have added a REST API resource that uses a bearer token for authentication. However, our current server implementation does not support a refresh token mechanism. To get a new token, we have to manually:

    1. Detect when the token expires (this throws a session error).
    2. Request a new access token from our server endpoint.
    3. Update the bearer token in the resource with the new token.
  • Details: In the current setup, obtaining a new bearer token requires manual intervention, which involves:

    1. Identifying that the token has expired due to a session error.
    2. Making a request to our server endpoint to retrieve a new access token.
    3. Updating the bearer token in the Retool resource with the new token.

Is there a way to automate this process so that the bearer token refreshes automatically upon expiration? Like we get the new token, and retool auto adds it as a bearer to the REST resource?

Hello!

There is! In this thread we are discussing using the refresh authorization on a 15 minute delay, however you should be able to build a refresh authorization to attempt to hit a validation endpoint to determine if the token is still working (re-auth when the response isn't 200, or is "bad_token" or whatever).