Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to properly update Access token #1882

Open
6 tasks done
dzhiganov opened this issue Oct 6, 2024 · 1 comment
Open
6 tasks done

How to properly update Access token #1882

dzhiganov opened this issue Oct 6, 2024 · 1 comment
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@dzhiganov
Copy link

Please make sure you have searched for information in the following guides.

Documentation Request

Hey there!

I found some information in the docs that I find confusing and would like to clarify.

In the OAuth2 section, when we call getAuthenticatedClient(), it seems like this should be done once, meaning we have a single client. However, in that case, I don’t understand how this part works: oAuth2Client.credentials.access_token. If we have multiple users, which user’s credentials would oAuth2Client.credentials return?

Or am I misunderstanding, and we actually need to create a new OAuth client instance for each user?

Also, I’m confused about the concept of setCredentials. For which user are the credentials being set? It seems like we should have multiple OAuth client instances.


My next question is about client.on('tokens'). I don’t understand for which user this handler will trigger. It seems like it would make more sense if we have multiple clients.

I’d also really appreciate it if you could explain the proper workflow for using client.on. Do we need to call setCredentials, and then, when the user makes a request with an expired access token, retrieve the token from oAuth2Client.credentials and update it on the client side? Is that correct? Also, I assume we should only update tokens if the provided access token is expired but still valid, right?

Sorry for asking so many questions at once, and thanks for your help!

@danielbankhead danielbankhead self-assigned this Oct 8, 2024
@danielbankhead danielbankhead added the type: question Request for information or clarification. Not an issue. label Oct 8, 2024
@danielbankhead
Copy link
Member

Hey @dzhiganov, the OAuthClient is designed for 1 context (e.g. user) at a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants