<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AuthenticationServices",
  "identifier" : "/documentation/AuthenticationServices/ASWebAuthenticationSessionRequest/cancelWithError(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Authentication Services"
    ],
    "preciseIdentifier" : "c:objc(cs)ASWebAuthenticationSessionRequest(im)cancelWithError:"
  },
  "title" : "cancelWithError(_:)"
}
-->

# cancelWithError(_:)

Indicates that the browser canceled the authentication attempt.

```
func cancelWithError(_ error: any Error)
```

## Parameters

`error`

An error with domain [`ASWebAuthenticationSessionErrorDomain`](/documentation/AuthenticationServices/ASWebAuthenticationSessionErrorDomain) and a suitable code from [`ASWebAuthenticationSessionError.Code`](/documentation/AuthenticationServices/ASWebAuthenticationSessionError/Code) that indicates the reason for the cancelation.

## Discussion

Call this method from your browser app when the authentication attempt fails to complete, for example because the user cancels it.

---

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)