Invalid token with invalid_grant
after a week
#2886
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Environment details
v12.22.8
6.14.15
googleapis
version:72.0.0
googl-auth-library
version:7.0.4
clientId
,clientSecret
,redirectUri
Issues
gmail
service fromgoogleapis
andoAuth2Client
fromgoogle-auth-library
packagesCloud functions used in application
cloud functions are deployed on gcp
functions
1)
and2)
are triggered only onceon function
3)
is set the cron job every houron function
4)
is set the cron job every dayFunctions used:
1) Login
oAuth2Client
Handle oAuth2 Callback
address with the query parametercode
with which new tokens are received2) Handle oAuth2 Callback
oAuth2Client
getToken
on an instance ofoAuth2Client
and pass a parameter as a query parameter from request obtained from a login function({access_token, expiry_date, id_token, refresh_token, token_type, scope})
which is stored in a databasesetCredentials
on an instanceoAuth2Client
and pass created tokens as an argumentgoogle.options({ auth: oAuth2Client })
so the gmail service can be used with the service accountwatch
methodvariable email is passed from a method
google.oauth2('v2‘)userinfo.get()
andPUBSUB_TOPIC
is set in a google console for the service account3) Sync mails
oAuth2Client
setCredentials
on an instanceOAuth2Client
and pass tokens as an argumentgetAccesToken
onoAuth2Client
instance to refresh tokens validitygoogle.options({auth: oAuth2Client})
4) Refresh Watch
oAuth2Client
setCredentials
on an instanceOAuth2Client
and pass tokens as an argumentgetAccesToken
onoAuth2Client
instancegoogle.options({auth: oAuth2Client})
watch
methodemail is passed as a
me
string andPUBSUB_TOPIC
is set in a google console for the service accountSteps done to try to fix the issue with invalid tokens
oAuth2Client
, callon
method and listen on an eventtokens
to update tokens in db, but this didn't helpinvalid_grant
occured -> tokens were invalidError that is showing up:
The text was updated successfully, but these errors were encountered: