i am using the AppAuth library for a custom single sign-on in my app written in objective c.
So far i have managed to get it to work in swift but when i use the same code converted to objective c the browser is not opened. This is what i have so far (have removed all urls and ids from the code included here, so dont mind that the strings are empty here):
In App Delegate:
@property(nonatomic, strong, nullable) id<OIDExternalUserAgentSession> currentAuthorizationFlow;
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *, id> *)options {
// Sends the URL to the current authorization flow (if any) which will process it if it relates to
// an authorization response.
if ([_currentAuthorizationFlow resumeExternalUserAgentFlowWithURL:url]) {
_currentAuthorizationFlow = nil;
return YES;
}
return NO;
}
And in viewcontroller:
- (IBAction)loginButtonAction:(id)sender {
NSURL *authorizationEndpoint = [NSURL URLWithString:@""];
NSURL *tokenEndpoint = [NSURL URLWithString:@""];
OIDServiceConfiguration *configuration = [[OIDServiceConfiguration alloc] initWithAuthorizationEndpoint:authorizationEndpoint tokenEndpoint:tokenEndpoint];
NSString *clientId = @"";
NSURL *redirectUri = [NSURL URLWithString:@""];
OIDAuthorizationRequest *builder = [[OIDAuthorizationRequest alloc] initWithConfiguration:configuration clientId:clientId scopes:@[OIDScopeOpenID] redirectURL:redirectUri responseType:OIDResponseTypeCode additionalParameters:nil];
// performs authentication request
AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
appDelegate.currentAuthorizationFlow = [OIDAuthState authStateByPresentingAuthorizationRequest:builder presentingViewController:self callback:^(OIDAuthState *_Nullable authState, NSError *_Nullable error) {
if (authState) {
NSLog(@"Got authorization tokens. Access token: %@", authState.lastTokenResponse.accessToken);
} else {
NSLog(@"Authorization error: %@", [error localizedDescription]);
}
}];
}
This opens up an alert asking the user if he/she wants to sign in, and if i press continue an external browser should open with the custom SSO page. The problem is that nothing happens after pressing continue.
Any ideas?