From eab6edb24f0e9748de24e93b83515008b90cdab7 Mon Sep 17 00:00:00 2001 From: Mahendra Nimishakavi Date: Wed, 6 Dec 2017 14:46:02 +0530 Subject: [PATCH] resolving defect where a server does not respond to the authorize call or there is a invalid redirect URI --- .../Classes/models/MASBrowserBasedAuthentication.m | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/MASFoundation/Classes/models/MASBrowserBasedAuthentication.m b/MASFoundation/Classes/models/MASBrowserBasedAuthentication.m index a605b165..8a9b792b 100644 --- a/MASFoundation/Classes/models/MASBrowserBasedAuthentication.m +++ b/MASFoundation/Classes/models/MASBrowserBasedAuthentication.m @@ -156,18 +156,21 @@ - (void)getURLForWebLogin // MASSessionDataTaskHTTPRedirectBlock previousRedirectionBlock = [[MASNetworkingService sharedService] httpRedirectionBlock]; [[MASNetworkingService sharedService] setHttpRedirectionBlock:[self getRedirectionBlock]]; + __block MASBrowserBasedAuthentication *blockSelf = self; // // This get request would result in a redirection which contains the actual URL to be loaded into browser and hence this would be canceled after the redirection // [[MASNetworkingService sharedService] getFrom:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:MASRequestResponseTypeWwwFormUrlEncoded responseType:MASRequestResponseTypeWwwFormUrlEncoded completion:^(NSDictionary* response, NSError* error){ - if(error) + // + // We expect this API to be cancelled in the redirection and hence the only acceptable error here is cancel.Any other error could mean an error for authenticaion itself. Hence cancel authorization. + // + if(error.code != NSURLErrorCancelled) { - // - // This error is expected as we cancel the Get request after the redirection - // - DLog(@"original request to get the url cancelled"); + DLog(@"error occured in BBA error info: %@",error); + blockSelf.webLoginCallBack(nil, YES, nil); + return; } [[MASNetworkingService sharedService] setHttpRedirectionBlock:previousRedirectionBlock];