mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 07:55:55 +03:00
[GH-ISSUE #396] PKCE Auth - refetch_token triggers status 400 bad request due to revoked refresh token #129
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#129
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 @ndoolan360 on GitHub (Mar 29, 2023).
Original GitHub issue: https://github.com/ramsayleung/rspotify/issues/396
Describe the bug
The
refetch_tokenmethod in theBaseClientofAuthCodePkceSpotifykeeps the original refresh_token after refetching causing an error response with Status 400 (Bad Request)To Reproduce
Steps to reproduce the behavior:
token_cacheExpected behavior
I expect the new refresh token returned by the request to be returned by
refetch_tokenand stored in the cache byrefresh_token.Log/Output data
log.txt
From recreating the request in postman the body is:
Additional context
This appears to occur because of auth_code_pkce.rs line 75
Spotify Community Discussion
Is this just to do with my use case?
Do we know why it is that we need to keep the same refresh_token after the refetch?
@ramsayleung commented on GitHub (May 30, 2023):
I think the refresh token logic the
pkcejust borrowed fromauth_code.rs, we should replace the old refresh token with the new fresh token retuned by the request.@mlehmk commented on GitHub (Jun 5, 2023):
The new refresh token is overwritten by the retained refresh token in line 77 of auth_code_pkce.rs of
github.com/ramsayleung/rspotify@4360c096f2/src/auth_code_pkce.rsRemoving that line seems to fix this issue
The PKCE protocol invalidates the old refresh token, due to a protection against token extraction. The token refresh also gives a new refresh token and remembers the old refresh token, so in case a refresh is issued with the old refresh token the whole session is invalidated.
@ramsayleung commented on GitHub (Jun 14, 2023):
This problem has been fixed, feel free to retry with the latest commit :)