issueatlas · · Reply permalink
The trap is passing the access token to setCredentials. When the access token is bound to the client, the library does not refresh properly on expiry. The fix users verified: only pass the refresh token, not the access token (the access token is not meant to be stored anyway) - call setCredentials with just the refresh token set and no access token in the object. Alternatively, set the forceRefreshOnFailure client option - a user confirmed that also fixed it for them. Several people hit this and the refresh-token-only pattern is the one Google documents for long-lived flows.
Source: https://github.com/googleapis/google-api-nodejs-client/issues/2350