# GetPublicKeyCredentialOption

Artifact: [androidx.credentials:credentials](https://developer.android.com/jetpack/androidx/releases/credentials) [View Source](https://cs.android.com/search?q=file:androidx/credentials/GetPublicKeyCredentialOption.kt+class:androidx.credentials.GetPublicKeyCredentialOption) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

*** ** * ** ***

<br />

```
class GetPublicKeyCredentialOption : CredentialOption
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.credentials.CredentialOption](https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption) ||
|   | ↳ | [androidx.credentials.GetPublicKeyCredentialOption](https://developer.android.com/reference/kotlin/androidx/credentials/GetPublicKeyCredentialOption) |

*** ** * ** ***

A request to get passkeys from the user's public key credential provider.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/credentials/GetPublicKeyCredentialOption#GetPublicKeyCredentialOption(kotlin.String,kotlin.ByteArray,kotlin.collections.Set)( requestJson: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, clientDataHash: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html?, allowedProviders: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/android/content/ComponentName.html> )` Constructs a `https://developer.android.com/reference/kotlin/androidx/credentials/GetPublicKeyCredentialOption`. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html?` | `https://developer.android.com/reference/kotlin/androidx/credentials/GetPublicKeyCredentialOption#clientDataHash()` a clientDataHash value to sign over in place of assembling and hashing clientDataJSON during the signature request; meaningful only if you have set the `https://developer.android.com/reference/kotlin/androidx/credentials/GetCredentialRequest#origin()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/GetPublicKeyCredentialOption#requestJson()` the request in JSON format in the standard webauthn web json shown [here](https://w3c.github.io/webauthn/#dictdef-publickeycredentialrequestoptionsjson). |

### Inherited properties

From [androidx.credentials.CredentialOption](https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/android/content/ComponentName.html>` `https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption#allowedProviders()`

a set of provider service `https://developer.android.com/reference/android/content/ComponentName.html` allowed to receive this option (Note: a `https://developer.android.com/reference/java/lang/SecurityException.html` will be thrown if it is set as non-empty but your app does not have android.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS; empty means every provider is eligible; for API level \< 34, this property will not take effect and you should control the allowed provider via [library dependencies](https://developer.android.com/training/sign-in/passkeys#add-dependencies))
`https://developer.android.com/reference/android/os/Bundle.html` `https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption#candidateQueryData()`

the partial request data in the `https://developer.android.com/reference/android/os/Bundle.html` format that will be sent to the provider during the initial candidate query stage, which will not contain sensitive user information
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption#isAutoSelectAllowed()`

whether a credential entry will be automatically chosen if it is the only one available option
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption#isSystemProviderRequired()`

true if must only be fulfilled by a system provider and false otherwise
`https://developer.android.com/reference/android/os/Bundle.html` `https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption#requestData()`

the request data in the `https://developer.android.com/reference/android/os/Bundle.html` format
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` `https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption#type()`

the credential type determined by the credential-type-specific subclass (e.g. the type for `https://developer.android.com/reference/kotlin/androidx/credentials/GetPasswordOption` is `https://developer.android.com/reference/kotlin/androidx/credentials/PasswordCredential#TYPE_PASSWORD_CREDENTIAL()` and for `https://developer.android.com/reference/kotlin/androidx/credentials/GetPublicKeyCredentialOption` is `https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL()`)
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption#typePriorityHint()`

sets the priority of this entry, which defines how it appears in the credential selector, with less precedence than account ordering but more precedence than last used time; see `https://developer.android.com/reference/kotlin/androidx/credentials/CredentialOption.PriorityHints` for more information

## Public constructors

### GetPublicKeyCredentialOption

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
GetPublicKeyCredentialOption(
    requestJson: String,
    clientDataHash: ByteArray? = null,
    allowedProviders: Set<ComponentName> = emptySet()
)
```

Constructs a `https://developer.android.com/reference/kotlin/androidx/credentials/GetPublicKeyCredentialOption`.

| Parameters |
|---|---|
| `requestJson: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the request in JSON format in the standard webauthn web json shown [here](https://w3c.github.io/webauthn/#dictdef-publickeycredentialrequestoptionsjson). |
| `clientDataHash: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html? = null` | a clientDataHash value to sign over in place of assembling and hashing clientDataJSON during the signature request; set only if you have set the `https://developer.android.com/reference/kotlin/androidx/credentials/GetCredentialRequest#origin()` |
| `allowedProviders: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/android/content/ComponentName.html> = emptySet()` | a set of provider service `https://developer.android.com/reference/android/content/ComponentName.html` allowed to receive this option (Note: a `https://developer.android.com/reference/java/lang/SecurityException.html` will be thrown if it is set as non-empty but your app does not have android.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS; for API level \< 34, this property will not take effect and you should control the allowed provider via [library dependencies](https://developer.android.com/training/sign-in/passkeys#add-dependencies)) |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/kotlin/androidx/credentials/GetPublicKeyCredentialOption#(kotlin.String,kotlin.ByteArray,kotlin.collections.Set)` is null |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If `https://developer.android.com/reference/kotlin/androidx/credentials/GetPublicKeyCredentialOption#(kotlin.String,kotlin.ByteArray,kotlin.collections.Set)` is empty, or if it is not a valid JSON |

## Public properties

### clientDataHash

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
val clientDataHash: ByteArray?
```

a clientDataHash value to sign over in place of assembling and hashing clientDataJSON during the signature request; meaningful only if you have set the `https://developer.android.com/reference/kotlin/androidx/credentials/GetCredentialRequest#origin()`

### requestJson

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/credentials#1.2.0)

```
val requestJson: String
```

the request in JSON format in the standard webauthn web json shown [here](https://w3c.github.io/webauthn/#dictdef-publickeycredentialrequestoptionsjson).