GetCredentialRequest
public final class GetCredentialRequest
Encapsulates a request to get a user credential.
An application can construct such a request by adding one or more types of CredentialOption, and then call CredentialManager.getCredential to launch framework UI flows to allow the user to consent to using a previously saved credential for the given application.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If |
Summary
Nested types |
|---|
public final class GetCredentialRequest.BuilderA builder for |
Public constructors |
|---|
GetCredentialRequest( |
Public methods |
|
|---|---|
static final @NonNull GetCredentialRequest |
@RequiresApi(value = 34)Parses the |
static final @NonNull GetCredentialRequest |
createFrom(Parses the raw data into an instance of |
final @NonNull List<@NonNull CredentialOption> |
the list of |
final String |
the origin of a different application if the request is being made on behalf of that application. |
final boolean |
the value which signals if the UI should be tailored to display an identity document like driver license etc. |
final ComponentName |
a service |
static final @NonNull Bundle |
Returns the request metadata as a |
final boolean |
true if you prefer the operation to return immediately when there is no available credentials instead of falling back to discovering remote options, and false (default) otherwise |
Public constructors
GetCredentialRequest
public GetCredentialRequest(
@NonNull List<@NonNull CredentialOption> credentialOptions,
String origin,
boolean preferIdentityDocUi,
ComponentName preferUiBrandingComponentName,
boolean preferImmediatelyAvailableCredentials
)
| Parameters | |
|---|---|
@NonNull List<@NonNull CredentialOption> credentialOptions |
the list of |
String origin |
the origin of a different application if the request is being made on behalf of that application (Note: for API level >=34, setting a non-null value for this parameter, will throw a SecurityException if android.permission.CREDENTIAL_MANAGER_SET_ORIGIN is not present) |
boolean preferIdentityDocUi |
the value which signals if the UI should be tailored to display an identity document like driver license etc |
ComponentName preferUiBrandingComponentName |
a service |
boolean preferImmediatelyAvailableCredentials |
true if you prefer the operation to return immediately when there is no available credentials instead of falling back to discovering remote options, and false (default) otherwise |
Public methods
createFrom
@RequiresApi(value = 34)
public static final @NonNull GetCredentialRequest createFrom(@NonNull GetCredentialRequest request)
Parses the request into an instance of GetCredentialRequest.
It is recommended to construct a GetCredentialRequest by direct constructor calls, instead of using this API. This API should only be used by a small subset of system apps that reconstruct an existing object for user interactions such as collecting consents.
| Parameters | |
|---|---|
@NonNull GetCredentialRequest request |
the framework GetCredentialRequest object |
createFrom
public static final @NonNull GetCredentialRequest createFrom(
@NonNull List<@NonNull CredentialOption> credentialOptions,
String origin,
@NonNull Bundle metadata
)
Parses the raw data into an instance of GetCredentialRequest.
It is recommended to construct a GetCredentialRequest by direct constructor calls, instead of using this API. This API should only be used by a small subset of system apps that reconstruct an existing object for user interactions such as collecting consents.
| Parameters | |
|---|---|
@NonNull List<@NonNull CredentialOption> credentialOptions |
|
String origin |
matches |
@NonNull Bundle metadata |
request metadata serialized as a Bundle using |
getCredentialOptions
public final @NonNull List<@NonNull CredentialOption> getCredentialOptions()
the list of CredentialOption from which the user can choose one to authenticate to the app
getOrigin
public final String getOrigin()
the origin of a different application if the request is being made on behalf of that application. For API level >=34, setting a non-null value for this parameter, will throw a SecurityException if android.permission.CREDENTIAL_MANAGER_SET_ORIGIN is not present.
getPreferIdentityDocUi
public final boolean getPreferIdentityDocUi()
the value which signals if the UI should be tailored to display an identity document like driver license etc.
getPreferUiBrandingComponentName
public final ComponentName getPreferUiBrandingComponentName()
a service ComponentName from which the Credential Selector UI will pull its label and icon to render top level branding. Your app must have the permission android.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS to specify this, or it would not take effect. Notice that this bit may not take effect for Android API level 33 and below, depending on the pre-34 provider(s) you have chosen.
getRequestMetadataBundle
public static final @NonNull Bundle getRequestMetadataBundle(@NonNull GetCredentialRequest request)
Returns the request metadata as a Bundle.
This API should only be used by OEM services and library groups.
Note: this is not the equivalent of the complete request itself. For example, it does not include the request's credentialOptions or origin.
preferImmediatelyAvailableCredentials
public final boolean preferImmediatelyAvailableCredentials()
true if you prefer the operation to return immediately when there is no available credentials instead of falling back to discovering remote options, and false (default) otherwise