# 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 />

```
public final class PublicKeyCredential extends Credential
```

<br />

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

*** ** * ** ***

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

## Summary

| ### Constants |
|---|---|
| `static 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/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL()` The type value for public key credential related operations. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/credentials/PublicKeyCredential#PublicKeyCredential(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html authenticationResponseJson)` Constructs a `https://developer.android.com/reference/androidx/credentials/PublicKeyCredential`. |

| ### Public methods |
|---|---|
| `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/PublicKeyCredential#getAuthenticationResponseJson()()` 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 methods

From [androidx.credentials.Credential](https://developer.android.com/reference/androidx/credentials/Credential) `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/Credential#getData()()`

the credential data in the `https://developer.android.com/reference/android/os/Bundle.html` format
`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/Credential#getType()()`

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

## Constants

### TYPE_PUBLIC_KEY_CREDENTIAL

```
public static final @NonNull String TYPE_PUBLIC_KEY_CREDENTIAL
```

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)

```
public PublicKeyCredential(@NonNull String authenticationResponseJson)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html 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) |

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

## Public methods

### getAuthenticationResponseJson

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

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

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)