Open
Description
I'm struggling trying to implement OAuth2 in a pm2 clustered environment. The example provided stores the new OAuthClient in a global variable. This is great if everyone is connecting to that one server instance. In production that is almost never the case.
I am going to assume that if process 1 and process 2 create wholly new OAuthClients, then access tokens returned to 2 will invalidate tokens in 1. Is that correct?
If so, I need a way to reconstitute an OAuthClient from data stored in a database. I imagine the flow will look like this:
- On connect request, check global variable is populated.
- If not, grab the access and refresh tokens and expiry from the database
- Recreate OAuthClient and manually and enter data from (2). HOW?
- If access token has expired, call RefreshToken() etc. ...