I am using oAuth2Client to access a user's Google Analytics property. Their refresh token is saved for future use. However, because the user could add multiple properties, I need to assign the refresh token to the user's Google account, not the GA Property. It looks like I should be able to identify Google accounts by their 'sub' string. This should be accessible within either the token_id or the credentials. I have tried both - token_id is not returned within the tokens object and credentials returns empty. Here is what I have tried:
import { google } from 'googleapis';
...
//POST token request to Google using received code
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uri);
const tokenRes = await oAuth2Client.getToken(code);
console.log(JSON.stringify(oAuth2Client.credentials));//{}
console.log(JSON.stringify(tokenRes.tokens));//{'access_token':'abc123', 'refresh_token':'1//abc123', etcButNoIdToken}