Specifically this is in regards to when we make a query to our API and the token is expired so our API returns a 401. We need to be able to log the user out of Retool if that happens.
Hey @david-watts! Today the best way to log a user out programmatically inside an app is to use a url redirect to the /logout endpoint in the current tab. In a JS query that would look like:
Or in a Go to URL event handler:
Thanks for the response!
So would we need to add something like this to each query to handle a 401 response or is there a more "global" way to catch errors and such?
You could create a single logout query as one Run JS Code query that is triggered in the on-failure event of any number of queries. Checking that the error code is a 401 would need to be manually written into the "Only run when" setting of the event handler there though to make sure that the user didn't get logged out with any type of failure code