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

refresh token #221

Open
TAMILVIP007 opened this issue Apr 16, 2023 · 4 comments
Open

refresh token #221

TAMILVIP007 opened this issue Apr 16, 2023 · 4 comments

Comments

@TAMILVIP007
Copy link

hey there i used this method to generate oauth token to get user's current playing track. It shows it expires after one hour. How can i refresh token if its expired? without running a web auth again

@cuotos
Copy link

cuotos commented May 31, 2023

this library is using the golang.org oauth2 client behind the scenes, it will handle the refresh for you when the token has expired.

"Client returns an HTTP client using the provided token. The token will auto-refresh as necessary. The underlying HTTP transport will be obtained using the provided context"

https://pkg.go.dev/golang.org/x/oauth2#Config.Client

@TAMILVIP007
Copy link
Author

Does it means i dont want to ask user to login each1h? after token gets expired?

@ATroschke
Copy link

this library is using the golang.org oauth2 client behind the scenes, it will handle the refresh for you when the token has expired.

"Client returns an HTTP client using the provided token. The token will auto-refresh as necessary. The underlying HTTP transport will be obtained using the provided context"

https://pkg.go.dev/golang.org/x/oauth2#Config.Client

I am sorry for waking this Thread up again, but is this true?

How can I hook into this?

Here is my current situation: I am asking users to connect their Spotify Account to my App to retrieve information about a User (specifically, their Followed Artists). I am then periodically synchronizing their Artists with a simple m2m Table in my DB and Fetching releases for my Users to display a proper and complete "New Releases" page.

I currently have an Issue where I frequently get revoked token Errors due to the refresh token already being used somewhere and had issues to track the exact place where it happens down.

@ATroschke
Copy link

I'm just gonna answer myself here.

Spotify revokes refresh tokens after a single use, and the OAuth2 library did indeed automatically refresh my users access token.

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

No branches or pull requests

3 participants