---
title: "password(withIdentifier:)"
framework: ManagedApp
role: symbol
role_heading: Instance Method
platforms: [iOS 18.4+, iPadOS 18.4+, macOS 27.0+, visionOS 2.4+]
path: "managedapp/managedapppasswordsprovider/password(withidentifier:)"
---

# password(withIdentifier:)

Provides a password by its identifier.

## Declaration

```swift
func password(withIdentifier identifier: String) async throws(ManagedAppError) -> String
```

## Parameters

- `identifier`: The identifier of the requested password. This function throws doc://com.apple.managedapp/documentation/ManagedApp/ManagedAppError/invalidIdentifier if the value you supply isn’t currently in doc://com.apple.managedapp/documentation/ManagedApp/ManagedAppIdentitiesProvider/identifiers.

## Mentioned in

Accessing provisioned secrets with identifiers

## Return Value

Return Value The requested password.

## Discussion

Discussion The MDM server can update the password at any time. After that, identifiers yields a new array of identifiers. Call this method again to obtain the updated password. The MDM server can change the available passwords at any time. When that happens, the list of valid identifiers updates accordingly. For example, the list of valid identifiers might change between the time that the app accesses identifiers and then calls this method passing in one of its elements. So, the app needs to handle the case that this method throws ManagedAppError.invalidIdentifier. important: Avoid storing the password and instead, call this method whenever the app needs the password. For security reasons, avoid logging or displaying the password. note: ManagedAppError.invalidIdentifier if no password exists with the specified identifier.
