<!--
{
  "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/ASWebAuthenticationSession/init(url:callback:completionHandler:)-6nut7",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Authentication Services"
    ],
    "preciseIdentifier" : "c:objc(cs)ASWebAuthenticationSession(im)initWithURL:callback:completionHandler:"
  },
  "title" : "init(url:callback:completionHandler:)"
}
-->

# init(url:callback:completionHandler:)

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

```
init(url URL: URL, callback: ASWebAuthenticationSession.Callback, completionHandler: @escaping ASWebAuthenticationSession.CompletionHandler)
```

## Parameters

`URL`

The initial URL pointing to the authentication webpage. This initializer only supports URLs with `http://` or `https://` schemes.

`callback`

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

`completionHandler`

A completion handler that the system calls when the session completes successfully, or when the person using the app cancels the request.

## Discussion

The following example creates a session that requires a callback with a custom URL scheme, using the [`customScheme(_:)`](/documentation/AuthenticationServices/ASWebAuthenticationSession/Callback/customScheme(_:)) type method to create the `callback` parameter:

```swift
let session = ASWebAuthenticationSession(
    url: URL(string: "https://example.com/oauth/login/authorize")!,
    callback: .customScheme("myappscheme")
) { callbackURL, error in
    // Handle the session result.
}
```

---

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)