Once a credential is created on your Android device, you can now use it to perform hybrid authentication across different devices.
Similar to registration requests, authentication requests require a set of options to invoke the ceremony. In this case your application will pass PublicKeyCredentialRequestOptions
into the browser’s navigator.credentials.get()
method.
Below is an example of a PublicKeyCredentialRequestOptions
object that can be used to invoke an authentication ceremony.
{
"publicKey": {
"challenge": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"rpId": "example.com",
"allowCredentials": [
{
"type": "public-key",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXX"
}
],
"userVerification": "preferred",
"extensions": {}
}
}
In this object, it is important that you include an allowCredentials list, that includes an item that denotes the credential that was created on your Android device. When a credential is created, it is given a credential ID. You will append that credential ID into the allowCredentials
list.
Overall, this list should contain the IDs of all of the credentials that belong to the user who is trying to authenticate into the application. So in our use case the list should hold two credentials: the one created by the security key, and the one created on the Android device.
Once invoked, the navigator.credentials.get()
method will display a list of options to the user (shown in the image below). The user will select “Another device”, and they will be presented with a QR code.
The user will scan the QR code with their phone, and complete the necessary user verification checks (PIN/Biometric/Pattern) on their phone. If completed successfully, then the credential will be passed to application, and the user will be authenticated.
Note
|
There is an option for a Pixel 7 Pro, the device used to generate the original credential. If the user has used this laptop before, they can prompt the previously used device, rather than invoking the QR code, as trust has already been established between the two devices.
|