Skip to content

Commit fd3738f

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

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-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
}

0 commit comments

Comments
 (0)