---
title: "cancelWithError(_:)"
framework: authenticationservices
role: symbol
role_heading: Instance Method
path: "authenticationservices/aswebauthenticationsessionrequest/cancelwitherror(_:)"
---

# cancelWithError(_:)

Indicates that the browser canceled the authentication attempt.

## Declaration

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

## Parameters

- `error`: An error with domain doc://com.apple.authenticationservices/documentation/AuthenticationServices/ASWebAuthenticationSessionErrorDomain and a suitable code from doc://com.apple.authenticationservices/documentation/AuthenticationServices/ASWebAuthenticationSessionError/Code that indicates the reason for the cancelation.

## Mentioned in

Supporting Single Sign-On in a Web Browser App

## Discussion

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

## See Also

### Finishing a request

- [callback](authenticationservices/aswebauthenticationsessionrequest/callback.md)
- [ASWebAuthenticationSession.Callback](authenticationservices/aswebauthenticationsession/callback.md)
- [complete(withCallbackURL:)](authenticationservices/aswebauthenticationsessionrequest/complete(withcallbackurl:).md)
