Class

ASWebAuthenticationSession

A session that an app uses to authenticate a user through a web service.

Declaration

class ASWebAuthenticationSession : NSObject

Overview

Use an ASWebAuthenticationSession instance to authenticate a user through a web service, including one run by a third party. Initialize the session with a URL that points to the authentication webpage. 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.

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.

For more details, see Authenticating a User Through a Web Service.

Topics

Creating a Session

Configuring a Session

var prefersEphemeralWebBrowserSession: Bool

A Boolean value that indicates whether the session should ask the browser for a private authentication session.

Starting and Stopping a Session

func start() -> Bool

Starts a web authentication session.

func cancel()

Cancels a web authentication session.

Presenting a Session

var presentationContextProvider: ASWebAuthenticationPresentationContextProviding?

A delegate that provides a display context in which the system can present an authentication session to the user.

protocol ASWebAuthenticationPresentationContextProviding

An interface the session uses to ask a delegate for a presentation context.

Recognizing Errors

struct ASWebAuthenticationSessionError

Errors that a web authentication session can generate.

Relationships

Inherits From

Conforms To

See Also

Web-Based Login

Authenticating a User Through a Web Service

Use a web authentication session to authenticate a user in your app.