# CustomCredential

# CustomCredential

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/credentials/CustomCredential "View this page in Java")

<br />

```
open class CustomCredential : 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.CustomCredential](https://developer.android.com/reference/kotlin/androidx/credentials/CustomCredential) |

*** ** * ** ***

Base class for a custom credential with which the user consented to authenticate to the app.

If you get a[CustomCredential](https://developer.android.com/reference/kotlin/androidx/credentials/CustomCredential)instead of a type-safe credential class such as[PasswordCredential](https://developer.android.com/reference/kotlin/androidx/credentials/PasswordCredential),[PublicKeyCredential](https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential), etc., then you should check if you have any other library at interest that supports this custom[type](https://developer.android.com/reference/kotlin/androidx/credentials/CustomCredential#type())of credential, and if so use its parsing utilities to resolve to a type-safe class within that library.

Note: The Bundle keys for[data](https://developer.android.com/reference/kotlin/androidx/credentials/CustomCredential#data())should not be in the form of`androidx.credentials.*`as they are reserved for internal use by this androidx library.  

|                                                             Throws                                                             |
|--------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.IllegalArgumentException](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html) | If[type](https://developer.android.com/reference/kotlin/androidx/credentials/CustomCredential#type())is empty                                                                                                     |
| [kotlin.NullPointerException](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html)         | If[data](https://developer.android.com/reference/kotlin/androidx/credentials/CustomCredential#data())or[type](https://developer.android.com/reference/kotlin/androidx/credentials/CustomCredential#type())is null |

## Summary

|                                                                                                                                                          ### Public constructors                                                                                                                                                          |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CustomCredential](https://developer.android.com/reference/kotlin/androidx/credentials/CustomCredential#CustomCredential(kotlin.String,android.os.Bundle))`(type: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, data: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)`)` |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ### Inherited properties                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.credentials.Credential](https://developer.android.com/reference/kotlin/androidx/credentials/Credential) |-----------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Bundle](https://developer.android.com/reference/android/os/Bundle.html)          | [data](https://developer.android.com/reference/kotlin/androidx/credentials/Credential#data()) the credential data in the[Bundle](https://developer.android.com/reference/android/os/Bundle.html)format                                                                                                                                                                                                                                                                                                                                                              | | [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [type](https://developer.android.com/reference/kotlin/androidx/credentials/Credential#type()) the credential type determined by the credential-type-specific subclass (e.g.[PasswordCredential.TYPE_PASSWORD_CREDENTIAL](https://developer.android.com/reference/kotlin/androidx/credentials/PasswordCredential#TYPE_PASSWORD_CREDENTIAL())for`PasswordCredential`or[PublicKeyCredential.TYPE_PUBLIC_KEY_CREDENTIAL](https://developer.android.com/reference/kotlin/androidx/credentials/PublicKeyCredential#TYPE_PUBLIC_KEY_CREDENTIAL())for`PublicKeyCredential`) | |

## Public constructors

### CustomCredential

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

```
CustomCredential(type: String, data: Bundle)
```  

|                                        Parameters                                         |
|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | the credential type determined by the credential-type-specific subclass for custom use cases                                                                                                                                                              |
| `data: `[Bundle](https://developer.android.com/reference/android/os/Bundle.html)          | the credential data in the[Bundle](https://developer.android.com/reference/android/os/Bundle.html)format for custom use cases (note: bundle keys in the form of`androidx.credentials.*`and`android.credentials.*`are reserved for internal library usage) |