<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AuthenticationServices",
  "identifier" : "/documentation/AuthenticationServices/ASAccountAuthenticationModificationExtensionContext/cancelRequest(withError:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Authentication Services"
    ],
    "preciseIdentifier" : "c:objc(cs)ASAccountAuthenticationModificationExtensionContext(im)cancelRequestWithError:"
  },
  "title" : "cancelRequest(withError:)"
}
-->

# cancelRequest(withError:)

Cancels a request with an error.

```
func cancelRequest(withError error: any Error)
```

## Parameters

`error`

An error that indicates the reason for the canceled request.

## Discussion

If the user cancels the request, use the [`ASExtensionError.Code.userCanceled`](/documentation/AuthenticationServices/ASExtensionError/Code/userCanceled) error code in the `error`. If the request requires user interaction, use [`ASExtensionError.Code.userInteractionRequired`](/documentation/AuthenticationServices/ASExtensionError/Code/userInteractionRequired) instead.

To include additional information regarding the failure, use [`ASExtensionLocalizedFailureReasonErrorKey`](/documentation/AuthenticationServices/ASExtensionLocalizedFailureReasonErrorKey) to set a string value in the error’s `userInfo` dictionary. The system displays this string value to the user.

---

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)