- 
                Notifications
    
You must be signed in to change notification settings  - Fork 284
 
Do not remove refresh_token on server errors #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
5609e3a
              6713930
              abb6229
              b231246
              9109c6c
              5cc44a2
              d664205
              7fe2e96
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -352,7 +352,7 @@ open class OAuth2: OAuth2Base { | |
| /** | ||
| If there is a refresh token, use it to receive a fresh access token. | ||
| 
     | 
||
| If the request returns an error, the refresh token is thrown away. | ||
| If the request returns an client error, the refresh token is thrown away. | ||
| 
     | 
||
| - parameter params: Optional key/value pairs to pass during token refresh | ||
| - parameter callback: The callback to call after the refresh token exchange has finished | ||
| 
        
          
        
         | 
    @@ -366,9 +366,14 @@ open class OAuth2: OAuth2Base { | |
| do { | ||
| let data = try response.responseData() | ||
| let json = try self.parseRefreshTokenResponseData(data) | ||
| if response.response.statusCode >= 400 { | ||
| switch response.response.statusCode { | ||
| case 400..<500: | ||
                
       | 
||
| self.clientConfig.refreshToken = nil | ||
| throw OAuth2Error.generic("Failed with status \(response.response.statusCode)") | ||
| case 500...599: | ||
| throw OAuth2Error.generic("Failed with status \(response.response.statusCode)") | ||
| default: | ||
| break | ||
| } | ||
| self.logger?.debug("OAuth2", msg: "Did use refresh token for access token [\(nil != self.clientConfig.accessToken)]") | ||
| callback(json, nil) | ||
| 
          
            
          
           | 
    ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for also updating the comment – can you change to "a client error"? :)