spotify
spotify copied to clipboard
refresh token
https://github.com/zmb3/spotify/blob/f897b41a6495bc134b79d4096d8d201f3970e344/examples/authenticate/authcode/authenticate.go#L31
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
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
Does it means i dont want to ask user to login each1h? after token gets expired?
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.
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.