question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why oAuth2Client.on('tokens') function never trigger ?

See original GitHub issue

Hi everyone, I’m facing to this issue. I used these below codes to refresh access_token. But I realize that it never triggers, although the access_token expired already:

oauth2client.on('tokens', (tokens) => {
  // But it never triggers
  // store the refresh_token in my database!
}

Do anyone have a workaround for this ? Additional:

oAuth2Client.refreshAccessToken((error, tokens) => {
  // return (Tokens is undefined) 
})

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bcoecommented, Jan 29, 2021

@shinichimg an access token is short lived. Once you have a refresh_token, try setting your credentials like this:

https://github.com/googleapis/google-auth-library-nodejs#retrieve-access-token

At which point, the next request to an API will request a new access token.

0reactions
rubek-joshicommented, Jun 8, 2021

@rubek-joshi could I bother you to open a new issue with your specific questions?

I’ve created one here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Authentication Token return doesn't contain ...
The refresh token is only sent once the first time user login to your application after approving the scopes you have specified.
Read more >
Refresh Tokens - OAuth 2.0 Simplified
The expiration time of the refresh token is intentionally never communicated to the client. This is because the client has no actionable steps...
Read more >
Google OAuth “invalid_grant” nightmare — and how to fix it
We had a lurking feeling that too many access tokens in a short time might trigger some temporary throttling by Google. A few...
Read more >
Understanding OAuth2 and Deploying a Basic ... - Medium
This tutorial deploys 3 Cloud Functions. The token function is responsible for issuing access tokens while the auth function and the signin ...
Read more >
Class OAuth2Client (8.7.0) | Node.js client library | Google Cloud
Constructs a new instance of the OAuth2Client class. Parameters ... Get a non-expired access token, after refreshing if necessary. Returns ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found