Skip to content

Commit

Permalink
Fix iosCustomBrowser not exchanging token (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
remacr authored Feb 16, 2024
1 parent 552831e commit 41126d4
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions ios/RNAppAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -409,26 +409,30 @@ - (void)authorizeWithConfiguration: (OIDServiceConfiguration *) configuration
}
}
} else {
OIDAuthStateAuthorizationCallback callback = ^(
OIDAuthState *_Nullable authState,
NSError *_Nullable error
) {
typeof(self) strongSelf = weakSelf;
strongSelf->_currentSession = nil;
[UIApplication.sharedApplication endBackgroundTask:rnAppAuthTaskId];
rnAppAuthTaskId = UIBackgroundTaskInvalid;
if (authState) {
resolve([self formatResponse:authState.lastTokenResponse
withAuthResponse:authState.lastAuthorizationResponse]);
} else {
reject([self getErrorCode: error defaultCode:@"authentication_failed"],
[self getErrorMessage: error], error);
}
};

if(externalUserAgent != nil) {
_currentSession = [OIDAuthorizationService presentAuthorizationRequest:request
_currentSession = [OIDAuthState authStateByPresentingAuthorizationRequest:request
externalUserAgent:externalUserAgent
callback:callback];
} else {
OIDAuthStateAuthorizationCallback callback = ^(OIDAuthState *_Nullable authState,
NSError *_Nullable error) {
typeof(self) strongSelf = weakSelf;
strongSelf->_currentSession = nil;
[UIApplication.sharedApplication endBackgroundTask:rnAppAuthTaskId];
rnAppAuthTaskId = UIBackgroundTaskInvalid;
if (authState) {
resolve([self formatResponse:authState.lastTokenResponse
withAuthResponse:authState.lastAuthorizationResponse]);
} else {
reject([self getErrorCode: error defaultCode:@"authentication_failed"],
[self getErrorMessage: error], error);
}
};


if (@available(iOS 13, *)) {
_currentSession = [OIDAuthState authStateByPresentingAuthorizationRequest:request
presentingViewController:presentingViewController
Expand Down

0 comments on commit 41126d4

Please sign in to comment.