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
- Create a new google oauth refresh token
- 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
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.
pbchess/server/src/services/email.service.js
Lines 13 to 32 in 42ccc48
To Reproduce π
Steps to reproduce the behavior:
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): π»
Additional context π
Related question on SO: https://stackoverflow.com/questions/66307450/why-my-google-drive-refresh-token-is-expiring-after-7-days