Hi all; I'm trying to implement ASWebAuthenticationSession on MacOS. The application must be able to open the default browser to interact with the IdP. The implemented code is basic, since what I am trying to understand is how to configure the framework to be able to open the system browser. Based on the documentation I observe this:
A browser loads and displays the page, from which the user can authenticate. In iOS, the browser is a secure, embedded web view. In macOS, the system opens the user’s default browser if it supports web authentication sessions, or Safari otherwise.
That is, it implies that this would be valid only for iOS, since a view is required where the content can be anchored. With which my understanding is that for MacOS that is not necessary, since the system browser is used.
However, when I try to compile the base example, Xcode throws the following message:
_Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=2 "Cannot start ASWebAuthenticationSession without providing presentation context.
The base code I'm using is very simple:
ASWebAuthenticationSession* webAuth = [[ASWebAuthenticationSession alloc] initWithURL:requestURL
callbackURLScheme:redirectScheme
completionHandler:^(NSURL * _Nullable callbackURL,NSError * _Nullable error)
{}];
webAuth.start;
All of this is required in Objective-C. All the examples that have been and will be are for iOS and all based on Swift.
Any reference about it to be able to implement this in MacOs?
Thanks and regards. Cristian.