In my nodejs server I am using '@google-cloud/local-auth' library to create events in calendar, when I authenticate to google calendar it returns me a client with refresh_token. What is the expiration time for this refresh_token?
public async authorize(): Promise<any> {
let authClient: any = await this.getSavedCredentialsIfExist();
if (authClient) {
return authClient;
}
authClient = await authenticate({
scopes: ['https://www.googleapis.com/auth/calendar'],
keyfilePath: CREDENTIALS_PATH
});
console.log('authClient', authClient);
if (authClient?.credentials) {
await this.saveCredentials(authClient.credentials.refresh_token);
}
return authClient;
}
Returned Client details:
{
"type":"authorized_user",
"client_id":"***",
"client_secret":"***",
"refresh_token":"***"
}
I looked at Google Calendar API documentation and didn't find the answer.
Please see oauth2#expiration
Refresh tokens are designed to be long lived and should not expire. For google though there are a few ways they can expire.
A Google Cloud Platform project with an OAuth consent screen configured for an external user type and a publishing status of "Testing" is issued a
refresh token expiring in 7 days, unless the only OAuth scopes requested are a subset of name, email address, and user profile (through the userinfo.email, userinfo.profile, openid scopes, or their OpenID Connect equivalents).Note on the last part this is testing not verification.