Issue #367: Refresh token expiration fix#409
Open
josephquigley wants to merge 1 commit intop2:masterfrom
Open
Conversation
…eared, preventing re-authorization.
97f014c to
01e8a9b
Compare
ossus-lib
reviewed
Oct 6, 2023
| catch let error { | ||
| // Fixes [Issue #367](https://github.com/p2/OAuth2/issues/367) | ||
| // Refresh token needs to be cleared out upon error, otherwise re-authorizing will not ocurr because the library thinks it has a valid refresh token and tries to fetch a new access token with an expired refresh token. | ||
| self.clientConfig.refreshToken = nil |
Collaborator
There was a problem hiding this comment.
This would clear the refresh token on any error, also e.g. when the server is temporarily unavailable (OAuth2Error.temporarilyUnavailable). I don't think this is desirable. The right way would be to check if the error is the invalid_grant error (which is thrown as OAuth2Error.invalidGrant) and delete the refresh token only in that case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
OAuth2.doRefreshTokenattempts to refresh an expired token that does not return an HTTP 400 error, then the re-authorization flow is never presented.A more detailed explanation of the fix is explained by @matthewtintabee in the issue itself: