<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 12.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AuthenticationServices",
  "identifier" : "/documentation/AuthenticationServices/ASWebAuthenticationSession",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Authentication Services"
    ],
    "preciseIdentifier" : "c:objc(cs)ASWebAuthenticationSession"
  },
  "title" : "ASWebAuthenticationSession"
}
-->

# ASWebAuthenticationSession

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

```
class ASWebAuthenticationSession
```

## Overview

Use an [`ASWebAuthenticationSession`](/documentation/AuthenticationServices/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. When the user starts the authentication session, the operating system shows a modal view telling them which domain the app is authenticating with and asking whether to proceed. If the user proceeds with the authentication attempt, 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. The session passes this URL back to the app through a completion handler. [`ASWebAuthenticationSession`](/documentation/AuthenticationServices/ASWebAuthenticationSession) ensures that only the calling app’s session receives the authentication callback, even when more than one app registers the same callback URL scheme.

For more details, see [Authenticating a User Through a Web Service](/documentation/AuthenticationServices/authenticating-a-user-through-a-web-service).

## Topics

### Creating a session

[`init(url:callback:completionHandler:)`](/documentation/AuthenticationServices/ASWebAuthenticationSession/init(url:callback:completionHandler:)-6nut7)

Creates a web authentication session instance that uses a callback to evaluate a redirection URL.

[`ASWebAuthenticationSession.Callback`](/documentation/AuthenticationServices/ASWebAuthenticationSession/Callback)

An object for evaluating navigation events in an authentication session.

[`ASWebAuthenticationSession.CompletionHandler`](/documentation/AuthenticationServices/ASWebAuthenticationSession/CompletionHandler)

A completion handler for the web authentication session.

### Configuring a session

[`prefersEphemeralWebBrowserSession`](/documentation/AuthenticationServices/ASWebAuthenticationSession/prefersEphemeralWebBrowserSession)

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

### Starting and Stopping a Session

[`canStart`](/documentation/AuthenticationServices/ASWebAuthenticationSession/canStart)

A Boolean indicating whether the session can begin.

[`start()`](/documentation/AuthenticationServices/ASWebAuthenticationSession/start())

Starts a web authentication session.

[`cancel()`](/documentation/AuthenticationServices/ASWebAuthenticationSession/cancel())

Cancels a web authentication session.

### Presenting a Session

[`presentationContextProvider`](/documentation/AuthenticationServices/ASWebAuthenticationSession/presentationContextProvider)

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

[`ASWebAuthenticationPresentationContextProviding`](/documentation/AuthenticationServices/ASWebAuthenticationPresentationContextProviding)

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

### Recognizing Errors

[`ASWebAuthenticationSessionError`](/documentation/AuthenticationServices/ASWebAuthenticationSessionError)

Errors that a web authentication session can generate.

[`ASWebAuthenticationSessionErrorDomain`](/documentation/AuthenticationServices/ASWebAuthenticationSessionErrorDomain)

The error domain for a web authentication session.

[`ASWebAuthenticationSessionError.Code`](/documentation/AuthenticationServices/ASWebAuthenticationSessionError/Code)

The error code for a web authentication session error.

### Initializers

### Instance properties

[`additionalHeaderFields`](/documentation/AuthenticationServices/ASWebAuthenticationSession/additionalHeaderFields)

Any additional header fields to set when loading the initial URL.

### Deprecated symbols

[`init(url:callbackURLScheme:completionHandler:)`](/documentation/AuthenticationServices/ASWebAuthenticationSession/init(url:callbackURLScheme:completionHandler:)-7fpox)

Creates a web authentication session instance.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)