I am using the node version of the google client api client. i.e.: google-api-nodejs-client .
As part of this, I am setting up oauth-flow ( 'google webserver' to be exact.)
As part of authentication, making calls such as:
var oauth2Client = new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
and
oauth2Client.setCredentials(userSpecificTokens)
Obviously, the first call is application specific, while the second call is user specific.
What is considered good practice in this case? or:
- have 1
oauth2Client and cache / save tokens per user and enter them using oauth2Client.setCredentials(userSpecificTokens) for each request. This essentially creates a new oauth2Client for each request. - has
oauthClient for each user, including oauth2Client.setCredentials(userSpecificTokens) , already applied, which is created when necessary and then cached afterwards.
source share