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

# prepareCredentialList(for:)

Prepares the interface to display a list of credentials from which the user can select.

```
func prepareCredentialList(for serviceIdentifiers: [ASCredentialServiceIdentifier])
```

## Parameters

`serviceIdentifiers`

An array of service identifiers that provide a hint about the service for which the user needs credentials.

## Discussion

The system calls this method to tell your extension’s view controller to prepare to present a list of credentials. After calling this method, the system presents the view controller to the user.

Use the given `serviceIdentifiers` array to filter or prioritize the credentials to display. The service identifier array might be empty, but your extension should still show credentials from which the user can pick.

Items in the array with lower indices represent more specific identifiers for which a credential’s requested. For example, if the array contains identifiers `[m.example.com, example.com]`, the item `m.example.com` represents the more specific service that requires a credential.

When the user selects a credential displayed by your view controller, encapsulate the corresponding user and password strings in an [`ASPasswordCredential`](/documentation/AuthenticationServices/ASPasswordCredential) instance and pass it to the extension context’s [`completeRequest(withSelectedCredential:completionHandler:)`](/documentation/AuthenticationServices/ASCredentialProviderExtensionContext/completeRequest(withSelectedCredential:completionHandler:)) method:

```swift
let passwordCredential = ASPasswordCredential(user: user, password: password)
extensionContext.completeRequest(withSelectedCredential: passwordCredential)
```

Alternatively, if the user cancels the operation, call the [`cancelRequest(withError:)`](/documentation/AuthenticationServices/ASCredentialProviderExtensionContext/cancelRequest(withError:)) method instead with an error that indicates user cancelation:

```swift
let error = NSError(domain: ASExtensionErrorDomain,
                    code: ASExtensionError.userCanceled.rawValue)
extensionContext.cancelRequest(withError: error)
```

Always provide a way for the user to cancel the operation from your view controller, for example by including a cancel button in the navigation bar.

The system dismisses your view controller automatically after you call either the completion or cancelation method.

---

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)