<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AuthenticationServices",
  "identifier" : "/documentation/AuthenticationServices/ASCredentialProviderViewController/prepareInterfaceToProvideCredential(for:)-68qpo",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Authentication Services"
    ],
    "preciseIdentifier" : "c:objc(cs)ASCredentialProviderViewController(im)prepareInterfaceToProvideCredentialForRequest:"
  },
  "title" : "prepareInterfaceToProvideCredential(for:)"
}
-->

# prepareInterfaceToProvideCredential(for:)

Prepare the view controller to show user interface for providing the requested credential.

```
func prepareInterfaceToProvideCredential(for credentialRequest: any ASCredentialRequest)
```

## Parameters

`credentialRequest`

The credential request.

## Discussion

The system calls this method when your extension can’t supply the requested credential without user interaction. Limit user interaction to operations required for providing the requested credential, like showing an authentication UI to unlock the person’s passwords database.

Call the appropriate completion method on the extension context to provide the credential. For password credentials, call [`completeRequest(withSelectedCredential:completionHandler:)`](/documentation/AuthenticationServices/ASCredentialProviderExtensionContext/completeRequest(withSelectedCredential:completionHandler:)). For passkey credentials, call [`completeAssertionRequest(using:completionHandler:)`](/documentation/AuthenticationServices/ASCredentialProviderExtensionContext/completeAssertionRequest(using:completionHandler:)). For one-time passcodes, call [`completeOneTimeCodeRequest(using:completionHandler:)`](/documentation/AuthenticationServices/ASCredentialProviderExtensionContext/completeOneTimeCodeRequest(using:completionHandler:)).

Alternatively, if an error occurs, call [`cancelRequest(withError:)`](/documentation/AuthenticationServices/ASCredentialProviderExtensionContext/cancelRequest(withError:)) instead and pass an error with domain [`ASExtensionErrorDomain`](/documentation/AuthenticationServices/ASExtensionErrorDomain) and an appropriate error code from [`ASExtensionError.Code`](/documentation/AuthenticationServices/ASExtensionError/Code). For example, if your app can’t find the credential identity in the database, pass an error with code [`ASExtensionError.Code.credentialIdentityNotFound`](/documentation/AuthenticationServices/ASExtensionError/Code/credentialIdentityNotFound).

---

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)