mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 07:55:55 +03:00
[GH-ISSUE #413] ClientCredsSpotify doesn't re-authenticate #134
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#134
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kangalio on GitHub (May 21, 2023).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/413
Describe the bug
An hour after after authenticating for the first time, every API call seems to fail
Http(StatusCode(Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("api.spotify.com")), port: None, path: "/v1/playlists/2gvPYPSGi6Eo0BWCauxOxp", query: None, fragment: None }, status: 401, headers: {"www-authenticate": "Bearer realm=\"spotify\", error=\"invalid_token\", error_description=\"The access token expired\"", "access-control-allow-origin": "*", "access-control-allow-headers": "Accept, App-Platform, Authorization, Content-Type, Origin, Retry-After, Spotify-App-Version, X-Cloud-Trace-Context, client-token, content-access-token", "access-control-allow-methods": "GET, POST, OPTIONS, PUT, DELETE, PATCH", "access-control-allow-credentials": "true", "access-control-max-age": "604800", "content-type": "application/json", "content-length": "81", "strict-transport-security": "max-age=31536000", "x-content-type-options": "nosniff", "vary": "Accept-Encoding", "date": "Sun, 21 May 2023 12:22:26 GMT", "server": "envoy", "via": "HTTP/2 edgeproxy, 1.1 google", "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"} }))To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expected RSpotify to re-authenticate automatically. That's how other API wrapper do it and is also how I would expect any high-level API wrapper to handle authentication. After all, it should abstract over the API, including authentication specifics.
@ramsayleung commented on GitHub (May 22, 2023):
RSpotifyis able to automatically refresh the token if it's expired, but this facility is disabled by default:https://github.com/ramsayleung/rspotify/blob/master/src/lib.rs#L265
If you want to enable
token_refreshing, settoken_refreshingtotrue:@kangalio commented on GitHub (May 23, 2023):
Interesting, why is it disabled by default?
@ramsayleung commented on GitHub (May 24, 2023):
Initially,
RSpotifydid not have auto-refreshing functionality. This feature was introduced three years after the creation ofRSpotify. To maintain compatibility and consistency with previous versions, we utilized a field to control this behavior and set it to false by default.You could check these issues and pull request for more details:
PS:
I think it's a better option to enable
auto refreshingby default.@ramsayleung commented on GitHub (Jun 7, 2023):
I think it's a good point, I would like to create a PR to set the
token_refreshingtotrueby default.@gdesmott commented on GitHub (Jul 29, 2023):
https://github.com/ramsayleung/rspotify/pull/429 has been merged. Can we close this?
@ramsayleung commented on GitHub (Jul 29, 2023):
Yes, I think we could close this now.