# BeginCreatePublicKeyCredentialRequest

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

*** ** * ** ***

<br />

```
public final class BeginCreatePublicKeyCredentialRequest extends BeginCreateCredentialRequest
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.credentials.provider.BeginCreateCredentialRequest](https://developer.android.com/reference/androidx/credentials/provider/BeginCreateCredentialRequest) ||
|   | ↳ | [androidx.credentials.provider.BeginCreatePublicKeyCredentialRequest](https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest) |

*** ** * ** ***

Request to begin registering a public key credential.

This request will not contain all parameters needed to create the public key. Provider must use the initial parameters to determine if the public key can be created, and return a `https://developer.android.com/reference/androidx/credentials/provider/BeginCreateCredentialResponse` containing a list of `https://developer.android.com/reference/androidx/credentials/provider/CreateEntry`, denoting the accounts/groups where the public key can be registered. When user selects one of the returned `https://developer.android.com/reference/androidx/credentials/provider/CreateEntry`, the corresponding `https://developer.android.com/reference/android/app/PendingIntent.html` set on the `https://developer.android.com/reference/androidx/credentials/provider/CreateEntry` will be fired. The `https://developer.android.com/reference/android/content/Intent.html` invoked through the `https://developer.android.com/reference/android/app/PendingIntent.html` will contain the complete `https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialRequest`. This request will contain all required parameters to actually register a public key.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest#requestJson()` or `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest#(kotlin.String,androidx.credentials.provider.CallingAppInfo,android.os.Bundle,kotlin.ByteArray)` is null |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest#requestJson()` is empty, or is not a valid JSON |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/credentials/provider/BeginCreateCredentialRequest` | Note: Credential providers are not expected to utilize the constructor in this class for any production flow. This constructor must only be used for testing purposes. |

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest#BeginCreatePublicKeyCredentialRequest(kotlin.String,androidx.credentials.provider.CallingAppInfo,android.os.Bundle,kotlin.ByteArray)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html requestJson, https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo callingAppInfo, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html candidateQueryData, byte[] clientDataHash )` constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest` |

| ### Public methods |
|---|---|
| `final byte[]` | `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest#getClientDataHash()()` a hash that is used to verify the relying party identity, set only if `https://developer.android.com/reference/android/service/credentials/CallingAppInfo.html#getOrigin()` is set |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest#getRequestJson()()` the request json to be used for registering the public key credential |

### Inherited methods

From [androidx.credentials.provider.BeginCreateCredentialRequest](https://developer.android.com/reference/androidx/credentials/provider/BeginCreateCredentialRequest) `final https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo` `https://developer.android.com/reference/androidx/credentials/provider/BeginCreateCredentialRequest#getCallingAppInfo()()` `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html` `https://developer.android.com/reference/androidx/credentials/provider/BeginCreateCredentialRequest#getCandidateQueryData()()` `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/androidx/credentials/provider/BeginCreateCredentialRequest#getType()()`

## Public constructors

### BeginCreatePublicKeyCredentialRequest

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

```
public BeginCreatePublicKeyCredentialRequest(
    @NonNull String requestJson,
    CallingAppInfo callingAppInfo,
    @NonNull Bundle candidateQueryData,
    byte[] clientDataHash
)
```

constructs an instance of `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html requestJson` | the request json to be used for registering the public key credential |
| `https://developer.android.com/reference/androidx/credentials/provider/CallingAppInfo callingAppInfo` | the information pertaining to the app requesting for credentials |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html candidateQueryData` | the raw bundle containing the request parameters, not expected to be used directly as all basic parameters are parsed into structured properties in this class like `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest#requestJson()` and `https://developer.android.com/reference/androidx/credentials/provider/BeginCreatePublicKeyCredentialRequest#clientDataHash()` |
| `byte[] clientDataHash` | a hash that is used to verify the relying party identity, set only if `https://developer.android.com/reference/android/service/credentials/CallingAppInfo.html#getOrigin()` is set |

## Public methods

### getClientDataHash

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

```
public final byte[] getClientDataHash()
```

a hash that is used to verify the relying party identity, set only if `https://developer.android.com/reference/android/service/credentials/CallingAppInfo.html#getOrigin()` is set

### getRequestJson

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

```
public final @NonNull String getRequestJson()
```

the request json to be used for registering the public key credential