What is the best approach for storing OAuth2 tokens?

In oauth2 provider, you can choose token handling to “session” in which case they are available as sessions variable… other option is to persist and retrieve ur tokens from a db (token handling is self-maintain), but i hv never tried this one! Don’t forget to click on the link icon to save ur oauth provider as an action file, like how u save a db connection!

If you choose the sessions way, in another server action files, u add the oauth provider, “connect” it to ur previously saved provider, and use it as “oauth” provider in ur api calls, this is the theory… See my other thread where I have raised a bug regarding this!

Meanwhile, instead of re-using your provider for token authorisation in ur api calls, u can manually add ur tokens to your own session variables and re-use them in ur api call authorisation header.

1 Like