OAuth2.0 Authentication with Retool for API Access

Hello Retool Community,

I am currently facing a challenge while integrating an application that uses OAuth2.0 authentication with Retool. (Moloni)

My process involves making two requests to access the API:

1 - The first request is to obtain an authorization_code (URL: https://api.moloni.pt/v1/authorize/?response_type=code&client_id=[your_developer_id]&redirect_uri=[your_callback_url] ).

2 - The second request uses this url to acquire a refreshToken and an accessToken for making API calls (URL: https://api.moloni.pt/v1/grant/?grant_type=authorization_code&client_id=[your_developer_id]&redirect_uri=[your_callback_url]&client_secret=[your_client_secret_code]&code=[your_authorization_code]).

However, the accessToken expires every hour, necessitating another request every 55 minutes to refresh it (URL: https://api.moloni.pt/v1/grant/?grant_type=refresh_token&client_id=[your_developer_id]&client_secret=[your_client_secret_code]&refresh_token=[your_refresh_token_code]). This is crucial for keeping the application operational.

I would appreciate any guidance or suggestions on how to efficiently manage this process within Retool. Is there a way to automate the token refresh process, or perhaps a more effective method to handle the OAuth2.0 authentication cycle?

Any insights or experiences shared would be greatly appreciated.

Thank you!

Hey @Goncalo_Santos! You can tell Retool how long the Access token is good for in the Advanced settings of the resource setup page.

Paired with a refresh flow, this should keep the token stored in Retool up to date. Let me know if you have any other questions!