# PublicKeyCredential

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

*** ** * ** ***

<br />

```
class PublicKeyCredential : Credential
```

<br />

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

*** ** * ** ***

Represents the user's passkey credential granted by the user for app sign-in.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL()` The type value for public key credential related operations. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential#PublicKeyCredential(kotlin.String)(authenticationResponseJson: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Constructs a `https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential`. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential#authenticationResponseJson()` the public key credential authentication response in JSON format that follows the standard webauthn json format shown at [this w3c link](https://w3c.github.io/webauthn/#dictdef-authenticationresponsejson) |

### Inherited properties

From [androidx.credentials.Credential](https://developer.android.com/reference/kotlin/androidx/credentials/Credential) `https://developer.android.com/reference/android/os/Bundle.html` `https://developer.android.com/reference/kotlin/androidx/credentials/Credential#data()`

the credential 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/Credential#type()`

the credential type determined by the credential-type-specific subclass (e.g. `https://developer.android.com/reference/kotlin/androidx/credentials/PasswordCredential#TYPE_PASSWORD_CREDENTIAL()` for `PasswordCredential` or `https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL()` for `PublicKeyCredential`)

## Constants

### TYPE_PUBLIC_KEY_CREDENTIAL

```
const val TYPE_PUBLIC_KEY_CREDENTIAL: String
```

The type value for public key credential related operations.

## Public constructors

### PublicKeyCredential

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

```
PublicKeyCredential(authenticationResponseJson: String)
```

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

| Parameters |
|---|---|
| `authenticationResponseJson: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the public key credential authentication response in JSON format that follows the standard webauthn json format shown at [this w3c link](https://w3c.github.io/webauthn/#dictdef-authenticationresponsejson) |

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

## Public properties

### authenticationResponseJson

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

```
val authenticationResponseJson: String
```

the public key credential authentication response in JSON format that follows the standard webauthn json format shown at [this w3c link](https://w3c.github.io/webauthn/#dictdef-authenticationresponsejson)