Skip to content

OAuth refresh token expiring after 7 daysΒ #134

Description

@adi-g15

Describe the bug πŸ›
After generating a refresh token, it is expiring after 7 days.
Due to this the sendMail function fails as the refresh token (and access token) wasn't valid then.

const oAuth2Client = new google.auth.OAuth2(googleClientID, googleClientSecret, redirectURL);
oAuth2Client.setCredentials({refresh_token: googleRefreshToken});
// Gets the access token at that moment
const accessToken = await oAuth2Client.getAccessToken();
// Transporter object specifying the type of email used
const transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth:{
type: 'OAuth2',
user: user,
clientId: googleClientID,
clientSecret: googleClientSecret,
refreshToken: googleRefreshToken,
accessToken: accessToken
}
});

To Reproduce πŸ”
Steps to reproduce the behavior:

It may take you to wait a week after creating a new refresh token

  1. Create a new google oauth refresh token
  2. Check after some days (general behaviour is after a week), the refresh token isn't valid, and calls requiring it fails too.

Expected behaviour 🐝
Access token are valid for short time, but the same is not true for refresh tokens, it should be able to send the mail.

Desktop (please complete the following information): πŸ’»

  • Windows 10
  • Firefox
  • Version 88.0

Additional context πŸ“
Related question on SO: https://stackoverflow.com/questions/66307450/why-my-google-drive-refresh-token-is-expiring-after-7-days

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is neededmoderateThis issue is moderately difficult

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions