API authentication Token valid for 3 days = must be generated regularly

Hello Weweb community,

I have a API authentication problem here.

I use Seatable for storing my data. Here is their authentication reference. API requests require an authentication via authentication-header.

I need a Base-Token to access my database. I can get that with an API Token using an API call : Get Base-Token with API-Token

I want to store the Base-Token to a variable in Weweb (in order to access my data in weweb) BUT Base-Token are valid for 3 days, therefore these must be generated regularly.

How would I go about making sure that I get a valid Base-Token consistently ? Maybe there is a way to have a cron event in weweb ?

Any help is appreciated.

one approach is to handle workflow errors when making requests with this api: of the error is because unauthorized (check the error code) then try to create a new token and retry the requests. Keep a count of retrials to put a stop to a possible loop.
also check the security needed for the api token, if you make requests with it from weweb every use will have access to it, so you may want to use it only in your backend.

Hello @dorilama my problem is not that I get workflow errors. The problem is that I have an API token that has a short life span of 3 days. I need to regenerate it on a regular basis.

I guess that I can trigger a workflow on page load and then re-fetch my collections everytime but that is slowing down the app.

Any idea on how that would be handled ?

Axel

I know you don’t get errors, I was describing a general way to handle an expiring token: at some point you will make a request that will fail because the token is expired and then you can request a new token and do the request again. it’s just one way of handling it

@dorilama I see I get it now ! Thanks. So I would incorporte this if statement to test if I get the unauthorized error into my workflow … I will try.

1 Like