Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,29 @@ client.passkeyEnrollmentChallenge()
```
</details>

<details>
<summary>Using Java</summary>

```java

MyAccountAPIClient client = new MyAccountAPIClient(account, "accessToken");

client.passkeyEnrollmentChallenge()
.start(new Callback<PasskeyEnrollmentChallenge, MyAccountException>() {
@Override
public void onSuccess(PasskeyEnrollmentChallenge result) {
System.out.println(result);
}

@Override
public void onFailure(@NonNull MyAccountException error) {
System.out.println(error);
}
});

```
</details>

#### 2. Create a new passkey credential

Use the enrollment challenge with the Google's [CredentialManager](https://developer.android.com/identity/sign-in/credential-manager) APIs to create a new passkey credential.
Expand All @@ -729,6 +752,32 @@ val passkeyCredentials = Gson().fromJson(
PublicKeyCredentials::class.java
)
```
<details>
<summary>Using Java</summary>

```java

CreateCredentialRequest request =
new CreatePublicKeyCredentialRequest(new Gson().toJson(enrollmentChallenge.authParamsPublicKey()));
credentialManager.createCredentialAsync(getContext(),
request,
cancellationSignal,
<executor>,
new CredentialManagerCallback<CreateCredentialResponse, CreateCredentialException>() {
@Override
public void onResult(CreateCredentialResponse createCredentialResponse) {
PublicKeyCredentials credentials = new Gson().fromJson(
((CreatePublicKeyCredentialResponse) createCredentialResponse).getRegistrationResponseJson(),
PublicKeyCredentials.class);
}
@Override
public void onError(@NonNull CreateCredentialException e) {}
});

```
</details>


#### 3. Enroll the passkey

Use the created passkey credential and the enrollment challenge to enroll the passkey with Auth0.
Expand Down Expand Up @@ -761,6 +810,27 @@ try {
```
</details>

<details>
<summary>Using Java</summary>

```java

client.enroll(passkeyCredential, challenge)
.start(new Callback<PasskeyAuthenticationMethod, MyAccountException>() {
@Override
public void onSuccess(@NonNull PasskeyAuthenticationMethod result) {
System.out.println("Passkey enrolled successfully: " + result.getId());
}

@Override
public void onFailure(@NonNull MyAccountException error) {
System.out.println("Error enrolling passkey: " + error.getMessage());
}
});

```
</details>

## Credentials Manager

### Secure Credentials Manager
Expand Down Expand Up @@ -897,6 +967,31 @@ credentialsManager.getApiCredentials(

</details>

<details>
<summary>Using Java</summary>

```java

credentialsManager.getApiCredentials("audience",
"scope",
0,
new HashMap<>(),
new HashMap<>(),
new Callback<APICredentials, CredentialsManagerException>() {
@Override
public void onSuccess(APICredentials result) {
System.out.println(result);
}

@Override
public void onFailure(@NonNull CredentialsManagerException error) {
System.out.println(error);
}
});

```
</details>

### Handling Credentials Manager exceptions

In the event that something happened while trying to save or retrieve the credentials, a `CredentialsManagerException` will be thrown. These are some of the expected failure scenarios:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public class MyAccountAPIClient @VisibleForTesting(otherwise = VisibleForTesting
* @return A request to obtain a passkey enrollment challenge
*
* */
@JvmOverloads
public fun passkeyEnrollmentChallenge(
userIdentity: String? = null, connection: String? = null
): Request<PasskeyEnrollmentChallenge, MyAccountException> {
Expand Down