Skip to content

Commit

Permalink
Fix authorization flow failing on iOS when server response has no data (
Browse files Browse the repository at this point in the history
  • Loading branch information
vmdominguez committed Jul 9, 2021
1 parent ae46df6 commit e9403f1
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,19 @@ public class OAuth2ClientPlugin: CAPPlugin {
call.reject(self.ERR_GENERAL)
}
}
} else {
} else if let responseData = response?.data {
do {
let jsonObj = try JSONSerialization.jsonObject(with: response!.data, options: []) as! JSObject
let jsonObj = try JSONSerialization.jsonObject(with: responseData, options: []) as! JSObject
call.resolve(jsonObj)
} catch {
self.log("Invalid json in response \(error.localizedDescription)")
call.reject(self.ERR_GENERAL)
}
} else {
// `parameters` will be response parameters
var result = parameters
result.updateValue(credential.oauthToken, forKey: self.JSON_KEY_ACCESS_TOKEN)
call.resolve(parameters)
}
case .failure(let error):
switch error {
Expand Down

0 comments on commit e9403f1

Please sign in to comment.