Last active
May 8, 2025 15:54
-
-
Save tdcolvin/7a47ca42e5be249a4b94ef8ef6c3e201 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
| // Get the registration options. | |
| // 'username' here is the requested username for the new account | |
| val registerRequestJson = getPasskeyRegisterRequestJson(username) | |
| // Create an object which holds the options needed to create the passkey | |
| val createPublicKeyCredentialRequest = CreatePublicKeyCredentialRequest( | |
| requestJson = registerRequestJson, | |
| // Pop up a UI | |
| preferImmediatelyAvailableCredentials = false | |
| ) | |
| // Finally show the UI, and guide the user to creating the passkey | |
| val createCredentialResponse = credentialManager.createCredential( | |
| context = localActivity, | |
| request = createPublicKeyCredentialRequest | |
| ) | |
| // Make sure Credential Manager created the right kind of credential | |
| if (createCredentialResponse !is CreatePublicKeyCredentialResponse) { | |
| throw Exception("Incorrect response type") | |
| } | |
| // The response is sent back to the server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment