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

Proposal: create Account from refreshing oauth2.TokenSource #29

Open
andig opened this issue Nov 3, 2023 · 6 comments · May be fixed by #151
Open

Proposal: create Account from refreshing oauth2.TokenSource #29

andig opened this issue Nov 3, 2023 · 6 comments · May be fixed by #151

Comments

@andig
Copy link

andig commented Nov 3, 2023

Creating account from token string and saving tokens inside the account is brittle since tokens expire. Instead, create Account by passing either an oauth2.Token or oauth2.TokenSource.

Using #24, these tokens would then be refreshed.

@andig andig changed the title Proposal: create Account from oauth.TokenSource Proposal: create Account from refreshing oauth2.TokenSource Nov 3, 2023
@andig
Copy link
Author

andig commented Dec 22, 2023

@sethterashima can I ask you to look into this issue? Its still unclear how to create long-running applications to handle access token expiry. It seems the idiomatic way doing this would be using an oauth2.TokenSource which #24 suggest.
Is this on the roadmap or do you expect library consumers to use account.New() on token expiry?

@andig
Copy link
Author

andig commented Jan 24, 2024

Friendly ping. This is an absolut blocker for any long-running application. How are applications supposed to perform token refresh with the current capabilities?

@fabianhu
Copy link
Contributor

@andig
Hi, maybe have a look at my implementation .
I just check, if I have to refresh the access token right before using it.
If it is expired I do a token refresh with the refresh token.
Or do I not get the question?

@andig
Copy link
Author

andig commented Jan 27, 2024

I just check, if I have to refresh the access token right before using it.

@fabianhu that's exactly what a Golang TokenSource does and is implemented in #151. Point here is that the Account is presumably something long-lived. That is not possible if it works on a static token.

Imho this proposal is a more go-ish and fully-featured way of doing things.

@pmpbaptista
Copy link
Contributor

@andig Hi, maybe have a look at my implementation . I just check, if I have to refresh the access token right before using it. If it is expired I do a token refresh with the refresh token. Or do I not get the question?

Currently I can only refresh tokens during +/- 24h ... after that, refreshing token returns 401 and I'm forced to login again to get a new CODE and then a new token/refresh_token

Does anyone know if I'm doing something wrong?
Current refresh logic - https://github.com/codesquadnest/tesla-smart-charger/blob/main/tesla_smart_charger/cron/token_cron.py

@andig are you aware of this issue?

@andig
Copy link
Author

andig commented Sep 1, 2024

Currently I can only refresh tokens during +/- 24h ... after that, refreshing token returns 401 and I'm forced to login again to get a new CODE and then a new token/refresh_token

When refreshing access tokens make sure to store the new refresh token, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants