Created
May 10, 2025 11:51
-
-
Save tdcolvin/a88cd75094e05ec3b336e89e1b923a75 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val localActivity = LocalActivity.current | |
| ... | |
| // Get the authentication request JSON from the server, using the code above | |
| val authenticationRequestJson = getPasskeyAuthenticationRequestJson(username) | |
| // Build the request for Credential Manager | |
| val getPublicKeyCredentialOption = GetPublicKeyCredentialOption( | |
| requestJson = authenticationRequestJson | |
| ) | |
| val signInRequest = GetCredentialRequest(listOf(getPublicKeyCredentialOption)) | |
| // Ask Credential Manager to process the sign-in request | |
| // This will pop up a dialog asking the user for their biometrics or PIN | |
| // (hence the need to pass in the activity) | |
| val result = credentialManager.getCredential( | |
| context = localActivity, | |
| request = signInRequest | |
| ) | |
| val credential = result.credential | |
| // Check that the returned credential is a passkey (PublicKeyCredential) | |
| if (credential !is PublicKeyCredential) { | |
| throw Exception("Incorrect credential type") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment