A session that an app uses to authenticate a user through a web service.
- iOS 12.0+
- macOS 10.15+
- Mac Catalyst 13.0+
ASWeb instance to authenticate a user through a web service, including one run by a third party. The system lets the user decide whether to use an existing, logged-in session, if one is available.
When you create an authentication session in your app, you provide a URL that points to the authentication webpage. A secure view controller loads and displays the page, from which the user can authenticate and grant access to the app. On completion, the service sends a callback URL to the session with an authentication token, and the session passes this URL back to the app through a completion handler.
The callback URL typically uses a custom URL scheme. For your app to receive the callback URL, either register the custom URL scheme in the app’s Information Property List file, or set the callbackURLScheme argument in the
If the user has already logged into the web service in Safari or other apps using
ASWeb, it’s possible to share the existing login information. The system presents the user with a dialog asking for consent to share login information. If the user cancels the alert, the session is canceled, and the completion handler is called with the error code
The app can cancel the session by calling the
cancel() method. This dismisses the view controller showing the web service’s login page.