Skip to content

Commit

Permalink
Add support for app2app on iOS
Browse files Browse the repository at this point in the history
If the user has an app installed that has a Universal Link registered
for the authorization endpoint, then launching that app will provide a
better user experience.

If the launch fails, we continue as before to use an in-app browser
tab etc.

See this OpenID Foundation blog post for further details:

https://openid.net/2019/10/21/guest-blog-implementing-app-to-app-authorisation-in-oauth2-openid-connect/

There was a question about whether to make this the default behaviour
or not; the documentation for OIDExternalUserAgentIOS says:

> An iOS specific external user-agent that uses the best possible
> user-agent available ...

so I think it's consistent with the documented goal to enable app2app
by default.
  • Loading branch information
jogu committed Jun 22, 2020
1 parent df840e8 commit 3bce2f7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Source/AppAuth/iOS/OIDExternalUserAgentIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,23 @@ - (BOOL)presentExternalUserAgentRequest:(id<OIDExternalUserAgentRequest>)request

_externalUserAgentFlowInProgress = YES;
_session = session;
NSURL *requestURL = [request externalUserAgentRequestURL];

// if authorization server has an app which is present & supports app2app, open it
if (@available(iOS 10.0, *)) {
[UIApplication.sharedApplication openURL:requestURL options:@{UIApplicationOpenURLOptionUniversalLinksOnly: @YES} completionHandler:^(BOOL success) {
if (!success) {
[self continuePresentExternalUserAgentRequest:request session:session];
}
}];
return YES;
} else {
return [self continuePresentExternalUserAgentRequest:request session:session];
}
}

- (BOOL)continuePresentExternalUserAgentRequest:(id<OIDExternalUserAgentRequest>)request
session:(id<OIDExternalUserAgentSession>)session {
BOOL openedUserAgent = NO;
NSURL *requestURL = [request externalUserAgentRequestURL];

Expand Down

0 comments on commit 3bce2f7

Please sign in to comment.