diff --git a/ios/OAuthManager/OAuth1Client.m b/ios/OAuthManager/OAuth1Client.m index 97ff342..b570104 100644 --- a/ios/OAuthManager/OAuth1Client.m +++ b/ios/OAuthManager/OAuth1Client.m @@ -31,13 +31,17 @@ - (void) authorizeWithUrl:(NSString *)providerName __weak id client = self; [account authenticateWithHandler:^(NSArray *responses, NSError *error) { - [client clearPendingAccount]; - if (error != nil) { - onError(error); + NSString *response = ((DCTAuthResponse *)responses[0]).responseDescription; + NSError *err = [NSError errorWithDomain:error.domain + code:error.code + userInfo:@{@"response": response}]; + onError(err); return; } + [client clearPendingAccount]; + if (!account.authorized) { NSError *err = QUICK_ERROR(E_ACCOUNT_NOT_AUTHORIZED, @"account not authorized"); onError(err); diff --git a/ios/OAuthManager/OAuth2Client.m b/ios/OAuthManager/OAuth2Client.m index d295ec3..092a255 100644 --- a/ios/OAuthManager/OAuth2Client.m +++ b/ios/OAuthManager/OAuth2Client.m @@ -34,13 +34,17 @@ - (void) authorizeWithUrl:(NSString *)providerName // authorizeWithClientID [account authenticateWithHandler:^(NSArray *responses, NSError *error) { NSLog(@"authenticateWithHandler: %@", responses); - [client clearPendingAccount]; if (error != nil) { - NSLog(@"Some error: %@", error); - onError(error); + NSString *response = ((DCTAuthResponse *)responses[0]).responseDescription; + NSError *err = [NSError errorWithDomain:error.domain + code:error.code + userInfo:@{@"response": response}]; + onError(err); return; } + + [client clearPendingAccount]; if (!account.authorized) { NSError *err = QUICK_ERROR(E_ACCOUNT_NOT_AUTHORIZED, @"account not authorized"); @@ -63,7 +67,10 @@ - (void) reauthenticateWithHandler:(NSString *) providerName [account reauthenticateWithHandler:^(DCTAuthResponse *response, NSError *error) { NSLog(@"Reauthenticating..."); if (error != nil) { - onError(error); + NSError *err = [NSError errorWithDomain:error.domain + code:error.code + userInfo:@{@"response": response.responseDescription}]; + onError(err); return; } diff --git a/ios/OAuthManager/OAuthManager.m b/ios/OAuthManager/OAuthManager.m index fd77ceb..df424fe 100644 --- a/ios/OAuthManager/OAuthManager.m +++ b/ios/OAuthManager/OAuthManager.m @@ -360,11 +360,12 @@ - (NSDictionary *) getConfigForProvider:(NSString *)name } onError:^(NSError *error) { NSLog(@"Error in authorizeWithUrl: %@", error); _pendingAuthentication = NO; - [manager removePending:client]; callback(@[@{ @"status": @"error", - @"msg": [error localizedDescription] + @"msg": [error localizedDescription], + @"userInfo": error.userInfo }]); + [manager removePending:client]; }]; }