Skip to content

Commit 97f014c

Browse files
committed
Fixes [Issue #367](#367) where expired refresh tokens were not cleared, preventing re-authorization.
1 parent 2934f35 commit 97f014c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Sources/Flows/OAuth2.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ open class OAuth2: OAuth2Base {
391391
callback(json, nil)
392392
}
393393
catch let error {
394+
// Fixes [Issue #367](https://github.com/p2/OAuth2/issues/367)
395+
// 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.
396+
self.clientConfig.refreshToken = nil
394397
self.logger?.debug("OAuth2", msg: "Error refreshing access token: \(error)")
395398
callback(nil, error.asOAuth2Error)
396399
}

Sources/Flows/OAuth2PasswordGrant.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ open class OAuth2PasswordGrant: OAuth2 {
6868

6969
/// Properties used to handle the native controller.
7070
open lazy var customAuthorizer: OAuth2CustomAuthorizerUI = OAuth2CustomAuthorizer()
71+
7172
/**
7273
If credentials are unknown when trying to authorize, the delegate will be asked a login controller to present.
7374

0 commit comments

Comments
 (0)