CredentialProvider
public interface CredentialProvider
Provider interface to be implemented by system credential providers that will fulfill Credential Manager requests. The implementation must have a constructor that takes in a context.
Note that for SDK version 33 and below, this interface can be implemented by any OEM provider that wishes to return credentials. The implementation must have a constructor with a context parameter. A provider must :
- Release a dedicated provider library that developers can add as a dependency.
- Include an empty CredentialProviderService in the provider library for the purposes of exposing a meta-data tag in the Android Manifest file.
- Add the name of the class that is implementing this interface, as a value to the meta-data tag described above.
- Make sure that there is only one provider implementation on the device. If the device already has a provider installed, and the developer specifies more than one provider dependencies, credential manager will error out.
For SDK version 34 and above, this interface will only be implemented by an internal class that will route all requests to the android framework. Providers will need to register directly with the framework to provide credentials.
Summary
Public methods
isAvailableOnDevice
abstract boolean isAvailableOnDevice()
Determines whether the provider is available on this device, or not.
onClearCredential
abstract void onClearCredential(
@NonNull ClearCredentialStateRequest request,
CancellationSignal cancellationSignal,
@NonNull Executor executor,
@NonNull CredentialManagerCallback<Void, @NonNull ClearCredentialException> callback
)
Invoked on a request to clear a credential.
| Parameters | |
|---|---|
@NonNull ClearCredentialStateRequest request |
the request for clearing the app user's credential state |
CancellationSignal cancellationSignal |
an optional signal that allows for cancelling this call |
@NonNull Executor executor |
the callback will take place on this executor |
@NonNull CredentialManagerCallback<Void, @NonNull ClearCredentialException> callback |
the callback invoked when the request succeeds or fails |
onCreateCredential
abstract void onCreateCredential(
@NonNull Context context,
@NonNull CreateCredentialRequest request,
CancellationSignal cancellationSignal,
@NonNull Executor executor,
@NonNull CredentialManagerCallback<@NonNull CreateCredentialResponse, @NonNull CreateCredentialException> callback
)
Invoked on a request to create a credential.
| Parameters | |
|---|---|
@NonNull Context context |
the client calling context used to potentially launch any UI needed |
@NonNull CreateCredentialRequest request |
the request for creating the credential |
CancellationSignal cancellationSignal |
an optional signal that allows for cancelling this call |
@NonNull Executor executor |
the callback will take place on this executor |
@NonNull CredentialManagerCallback<@NonNull CreateCredentialResponse, @NonNull CreateCredentialException> callback |
the callback invoked when the request succeeds or fails |
onGetCredential
@RequiresApi(value = 34)
default void onGetCredential(
@NonNull Context context,
@NonNull PrepareGetCredentialResponse.PendingGetCredentialHandle pendingGetCredentialHandle,
CancellationSignal cancellationSignal,
@NonNull Executor executor,
@NonNull CredentialManagerCallback<@NonNull GetCredentialResponse, @NonNull GetCredentialException> callback
)
Complete on a request to get a credential represented by the pendingGetCredentialHandle.
| Parameters | |
|---|---|
@NonNull Context context |
the client calling context used to potentially launch any UI needed |
@NonNull PrepareGetCredentialResponse.PendingGetCredentialHandle pendingGetCredentialHandle |
the handle representing the pending operation to resume |
CancellationSignal cancellationSignal |
an optional signal that allows for cancelling this call |
@NonNull Executor executor |
the callback will take place on this executor |
@NonNull CredentialManagerCallback<@NonNull GetCredentialResponse, @NonNull GetCredentialException> callback |
the callback invoked when the request succeeds or fails |
onGetCredential
abstract void onGetCredential(
@NonNull Context context,
@NonNull GetCredentialRequest request,
CancellationSignal cancellationSignal,
@NonNull Executor executor,
@NonNull CredentialManagerCallback<@NonNull GetCredentialResponse, @NonNull GetCredentialException> callback
)
Invoked on a request to get a credential.
| Parameters | |
|---|---|
@NonNull Context context |
the client calling context used to potentially launch any UI needed |
@NonNull GetCredentialRequest request |
the request for getting the credential |
CancellationSignal cancellationSignal |
an optional signal that allows for cancelling this call |
@NonNull Executor executor |
the callback will take place on this executor |
@NonNull CredentialManagerCallback<@NonNull GetCredentialResponse, @NonNull GetCredentialException> callback |
the callback invoked when the request succeeds or fails |
onPrepareCredential
@RequiresApi(value = 34)
default void onPrepareCredential(
@NonNull GetCredentialRequest request,
CancellationSignal cancellationSignal,
@NonNull Executor executor,
@NonNull CredentialManagerCallback<@NonNull PrepareGetCredentialResponse, @NonNull GetCredentialException> callback
)
Invoked on a request to prepare for a get-credential operation
| Parameters | |
|---|---|
@NonNull GetCredentialRequest request |
the request for getting the credential |
CancellationSignal cancellationSignal |
an optional signal that allows for cancelling this call |
@NonNull Executor executor |
the callback will take place on this executor |
@NonNull CredentialManagerCallback<@NonNull PrepareGetCredentialResponse, @NonNull GetCredentialException> callback |
the callback invoked when the request succeeds or fails |
onSignalCredentialState
default void onSignalCredentialState(
@NonNull SignalCredentialStateRequest request,
@NonNull Executor executor,
@NonNull CredentialManagerCallback<@NonNull SignalCredentialStateResponse, @NonNull SignalCredentialStateException> callback
)
Invoked on a request to signal an app user's credential state
| Parameters | |
|---|---|
@NonNull SignalCredentialStateRequest request |
the request for signaling the app user's credential state |
@NonNull Executor executor |
the callback will take place on this executor |
@NonNull CredentialManagerCallback<@NonNull SignalCredentialStateResponse, @NonNull SignalCredentialStateException> callback |
the callback invoked when the request succeeds or fails |