Refresh a token (Multiple Oauth2Clients)
See original GitHub issueSo, i was reading the docs and i saw the only way to refresh a token is this
oauth2client.on('tokens', (tokens) => {
if (tokens.refresh_token) {
// store the refresh_token in my database!
console.log(tokens.refresh_token);
}
console.log(tokens.access_token);
});
Isn’t it inefficient to add an event to every single client? isn’t there a better way to manually check the clients access token and refresh it using the refresh token?
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
how many refresh tokens and access tokens can one single ...
With OAuth2 a clientID will only have 1 active set of tokens (access+refresh). If you have multiple ClientID's from the API you can...
Read more >OAuth with PHP Part Two: refreshing & revoking tokens
Here is what it looks like with PHP using file_get_contents code: //Refresh the token $url = "[https://connect.squareup.com/oauth2/clients/$ ...
Read more >How to Automatically Request and Refresh OAuth2 Client ...
The response from the authorization server includes an access token which then must be passed on the request to Order Service in order...
Read more >Refresh Tokens - ForgeRock Backstage
Refresh tokens (RFC 6749) are a type of token that can be used to obtain a new access token that may have identical...
Read more >Multiple valid refresh tokens at the same time. - Microsoft Q&A
Multiple valid refresh tokens at the same time. I got a token and a refresh token following https://docs.microsoft.com/en-us/azure/active- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@richardpeng I agree.
@bcoe The
tokens
event can’t access application context. Where should I put this.on("tokens")
in application code?For example, if use
express
, the context info is attached inreq
object, likereq.user
I think below way is wrong:
If put
auth.on('tokens', (tokens) => {})
on a global environmentHey! I randomly came across this issue and I actually wanted to ask something very similar to @supertiger1234 asked.
What if I want to save the new token to the database? Using the listener becomes very hard in that matter. What is your suggestion?