<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "macCatalyst: 17.4.0 -",
    "macOS: 14.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.1.0 -",
    "watchOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AuthenticationServices",
  "identifier" : "/documentation/AuthenticationServices/WebAuthenticationSession/authenticate(using:callback:preferredBrowserSession:additionalHeaderFields:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Authentication Services",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:31_AuthenticationServices_SwiftUI03WebA7SessionV12authenticate5using8callback016preferredBrowserF022additionalHeaderFields10Foundation3URLVAK_So05ASWebaF8CallbackCAC0kF0VSgSDyS2SGtYaKF"
  },
  "title" : "authenticate(using:callback:preferredBrowserSession:additionalHeaderFields:)"
}
-->

# authenticate(using:callback:preferredBrowserSession:additionalHeaderFields:)

Begins a web authentication session.

```
@MainActor func authenticate(using url: URL, callback: ASWebAuthenticationSession.Callback, preferredBrowserSession: WebAuthenticationSession.BrowserSession? = nil, additionalHeaderFields: [String : String]) async throws -> URL
```

## Parameters

`url`

A URL beginning with HTTP or HTTPS that points to the authentication webpage.

`callback`

An object that describes when the session calls its completion handler.

`preferredBrowserSession`

The preferred data-sharing behavior of the browser session. For more information, see [`WebAuthenticationSession.BrowserSession`](/documentation/AuthenticationServices/WebAuthenticationSession/BrowserSession).

`additionalHeaderFields`

A dictionary containing additional header fields to send when loading the initial URL.

## Discussion

This initializer throws an error if `additionalHeaderFields` includes a “forbidden request-header” as defined by the WHATWG.

---

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)