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

# prepareInterfaceToProvideCredential(for:)

Prepares the interface for a user interaction, like a database login, that enables it to access and return the credential for the given identity.

```
func prepareInterfaceToProvideCredential(for credentialIdentity: ASPasswordCredentialIdentity)
```

## Parameters

`credentialIdentity`

The credential identity for which a credential should be provided.

## Discussion

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

Call the context’s [`completeRequest(withSelectedCredential:completionHandler:)`](/documentation/AuthenticationServices/ASCredentialProviderExtensionContext/completeRequest(withSelectedCredential:completionHandler:)) to provide the credential. 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)