# CreateCredentialResponse

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

*** ** * ** ***


```
public abstract class CreateCredentialResponse
```

<br />

Known direct subclasses [CreateCustomCredentialResponse](https://developer.android.com/reference/androidx/credentials/CreateCustomCredentialResponse), [CreateDigitalCredentialResponse](https://developer.android.com/reference/androidx/credentials/CreateDigitalCredentialResponse), [CreatePasswordResponse](https://developer.android.com/reference/androidx/credentials/CreatePasswordResponse), [CreatePublicKeyCredentialResponse](https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialResponse), [CreateRestoreCredentialResponse](https://developer.android.com/reference/androidx/credentials/CreateRestoreCredentialResponse)

|---|---|
| `https://developer.android.com/reference/androidx/credentials/CreateCustomCredentialResponse` | Base custom create response class for the credential creation operation made with the `https://developer.android.com/reference/androidx/credentials/CreateCustomCredentialRequest`. |
| `https://developer.android.com/reference/androidx/credentials/CreateDigitalCredentialResponse` | A response of creating a digital credential. |
| `https://developer.android.com/reference/androidx/credentials/CreatePasswordResponse` | A response of a password saving flow. |
| `https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialResponse` | A response of a public key credential (passkey) flow. |
| `https://developer.android.com/reference/androidx/credentials/CreateRestoreCredentialResponse` | A response of the `https://developer.android.com/reference/androidx/credentials/RestoreCredential` flow. |

*** ** * ** ***

Base response class for the credential creation operation made with the `https://developer.android.com/reference/androidx/credentials/CreateCredentialRequest`.

```kotlin
import androidx.credentials.CreateCustomCredentialResponse
import androidx.credentials.CreatePasswordResponse
import androidx.credentials.CreatePublicKeyCredentialResponse
import androidx.credentials.Credential
import androidx.credentials.CustomCredential
import androidx.credentials.PublicKeyCredential

when (response) {
    is CreatePasswordResponse ->
        // Password saved successfully, proceed to signed in experience.
        loginWithPassword()
    is CreatePublicKeyCredentialResponse ->
        // Validate and register the registration json from your server, and if successful
        // proceed to signed in experience.
        loginWithPasskey(response.registrationResponseJson)
    is CreateCustomCredentialResponse -> {
        // If you are also using any external sign-in libraries, parse them here with the
        // utility functions provided they provided.
        if (response.type == ExampleCustomCredential.TYPE) {
            try {
                val createExampleCustomCredentialResponse =
                    CreateExampleCustomCredentialResponse.createFrom(response)
                loginWithExampleCustomCredential(createExampleCustomCredentialResponse)
            } catch (e: CreateExampleCustomCredentialResponse.ParsingException) {
                // Unlikely to happen. If it does, you likely need to update the dependency
                // version of your external sign-in library.
                Log.e(TAG, "Failed to parse a CreateExampleCustomCredentialResponse", e)
            }
        } else {
            Log.w(
                TAG,
                "Received unrecognized response type ${response.type}. " +
                    "This shouldn't happen",
            )
        }
    }
    else -> {
        Log.w(
            TAG,
            "Received unrecognized response type ${response.type}. This shouldn't happen",
        )
    }
}
```

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse` | `https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse#createFrom(kotlin.String,android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html type, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html data)` Parses the raw data into an instance of `https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse`. |
| `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/CreateCredentialResponse#getData()()` the response 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/CreateCredentialResponse#getType()()` the credential type determined by the credential-type-specific subclass (e.g. the type for `https://developer.android.com/reference/androidx/credentials/CreatePasswordResponse` is `https://developer.android.com/reference/androidx/credentials/PasswordCredential#TYPE_PASSWORD_CREDENTIAL()` and for `https://developer.android.com/reference/androidx/credentials/CreatePublicKeyCredentialResponse` is `https://developer.android.com/reference/androidx/credentials/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL()`) |

## Public methods

### createFrom

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

```
public static final @NonNull CreateCredentialResponse createFrom(@NonNull String type, @NonNull Bundle data)
```

Parses the raw data into an instance of `https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse`.

It is recommended to construct a CreateCredentialResponse by directly instantiating a CreateCredentialResponse subclass, instead of using this API. This API should only be used by a small subset of system apps that reconstruct an existing object across IPC.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html type` | matches `https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse#type()`, the credential type of the response |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/Bundle.html data` | matches `https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse#data()`, the credential response data in the `https://developer.android.com/reference/android/os/Bundle.html` format; this should be constructed and retrieved from the a given `https://developer.android.com/reference/androidx/credentials/CreateCredentialResponse` itself and never be created from scratch |

### getData

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

```
public final @NonNull Bundle getData()
```

the response data in the `https://developer.android.com/reference/android/os/Bundle.html` format

### getType

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

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

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