Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
315 changes: 315 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
- [DPoP [EA]](#dpop-ea-1)
- [My Account API](#my-account-api)
- [Enroll a new passkey](#enroll-a-new-passkey)
- [Get Available Factors](#get-available-factors)
- [Get All Enrolled Authentication Methods](#get-all-enrolled-authentication-methods)
- [Get a Single Authentication Method by ID](#get-a-single-authentication-method-by-id)
- [Enroll a Phone Method](#enroll-a-phone-method)
- [Enroll an Email Method](#enroll-an-email-method)
- [Enroll a TOTP (Authenticator App) Method](#enroll-a-totp-authenticator-app-method)
- [Enroll a Push Notification Method](#enroll-a-push-notification-method)
- [Enroll a Recovery Code](#enroll-a-recovery-code)
- [Verify an Enrollment](#verify-an-enrollment)
- [Update an Authentication Method](#update-an-authentication-method)
- [Delete an Authentication Method](#delete-an-authentication-method)
- [Credentials Manager](#credentials-manager)
- [Secure Credentials Manager](#secure-credentials-manager)
- [Usage](#usage)
Expand Down Expand Up @@ -959,6 +970,310 @@ client.enroll(passkeyCredential, challenge)
```
</details>

### Get Available Factors
**Scopes required:** `read:me:factors`
```kotlin
myAccountClient.getFactors()
.start(object : Callback<List<Factor>, MyAccountException> {
override fun onSuccess(result: Factors) {
// List of available factors in result.factors
}
override fun onFailure(error: MyAccountException) { }
})
```
<details>
<summary>Using Java</summary>

```java
myAccountClient.getFactors()
.start(new Callback<List<Factor>, MyAccountException>() {
@Override
public void onSuccess(Factors result) {
// List of available factors in result.getFactors()
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```</details>

### Get All Enrolled Authentication Methods
**Scopes required:** `read:me:authentication_methods`
```kotlin
myAccountClient.getAuthenticationMethods()
.start(object : Callback<List<AuthenticationMethod>, MyAccountException> {
override fun onSuccess(result: AuthenticationMethods) {
// List of enrolled methods in result.authenticationMethods
}
override fun onFailure(error: MyAccountException) { }
})
```
<details>
<summary>Using Java</summary>

```java
myAccountClient.getAuthenticationMethods()
.start(new Callback<List<AuthenticationMethod>, MyAccountException>() {
@Override
public void onSuccess(AuthenticationMethods result) {
// List of enrolled methods in result.getAuthenticationMethods()
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```
</details>

### Get a Single Authentication Method by ID
**Scopes required:** `read:me:authentication_methods`
```kotlin
myAccountClient.getAuthenticationMethodById("phone|dev_...")
.start(object : Callback<AuthenticationMethod, MyAccountException> {
override fun onSuccess(result: AuthenticationMethod) {
// The requested authentication method
}
override fun onFailure(error: MyAccountException) { }
})
```
<details>
<summary>Using Java</summary>

```java
myAccountClient.getAuthenticationMethodById("phone|dev_...")
.start(new Callback<AuthenticationMethod, MyAccountException>() {
@Override
public void onSuccess(AuthenticationMethod result) {
// The requested authentication method
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```
</details>

### Enroll a Phone Method
**Scopes required:** `create:me:authentication_methods`
```kotlin
myAccountClient.enrollPhone("+11234567890", PhoneAuthenticationMethodType.SMS)
.start(object : Callback<EnrollmentChallenge, MyAccountException> {
override fun onSuccess(result: EnrollmentChallenge) {
// OTP sent. Use result.id and result.authSession to verify.
}
override fun onFailure(error: MyAccountException) { }
})
```
<details>
<summary>Using Java</summary>

```java
myAccountClient.enrollPhone("+11234567890", PhoneAuthenticationMethodType.SMS)
.start(new Callback<EnrollmentChallenge, MyAccountException>() {
@Override
public void onSuccess(EnrollmentChallenge result) {
// OTP sent. Use result.getId() and result.getAuthSession() to verify.
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```
</details>

### Enroll an Email Method
**Scopes required:** `create:me:authentication_methods`
```kotlin
myAccountClient.enrollEmail("user@example.com")
.start(object : Callback<EnrollmentChallenge, MyAccountException> {
override fun onSuccess(result: EnrollmentChallenge) {
// OTP sent. Use result.id and result.authSession to verify.
}
override fun onFailure(error: MyAccountException) { }
})
```
<details>
<summary>Using Java</summary>

```java
myAccountClient.enrollEmail("user@example.com")
.start(new Callback<EnrollmentChallenge, MyAccountException>() {
@Override
public void onSuccess(EnrollmentChallenge result) {
// OTP sent. Use result.getId() and result.getAuthSession() to verify.
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```
</details>

### Enroll a TOTP (Authenticator App) Method
**Scopes required:** `create:me:authentication_methods`
```kotlin
myAccountClient.enrollTotp()
.start(object : Callback<TotpEnrollmentChallenge, MyAccountException> {
override fun onSuccess(result: TotpEnrollmentChallenge) {
// The result is already a TotpEnrollmentChallenge, no cast is needed.
// Show QR code from result.barcodeUri or manual code from result.manualInputCode
// Then use result.id and result.authSession to verify.
}
override fun onFailure(error: MyAccountException) { }
})```
<details>
<summary>Using Java</summary>

```java
myAccountClient.enrollTotp()
.start(new Callback<TotpEnrollmentChallenge, MyAccountException>() {
@Override
public void onSuccess(TotpEnrollmentChallenge result) {
// The result is already a TotpEnrollmentChallenge, no cast is needed.
// Show QR code from result.getBarcodeUri() or manual code from result.getManualInputCode()
// Then use result.getId() and result.getAuthSession() to verify.
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```
</details>

### Enroll a Push Notification Method
**Scopes required:** `create:me:authentication_methods`
```kotlin
myAccountClient.enrollPushNotification()
.start(object : Callback<TotpEnrollmentChallenge, MyAccountException> {
override fun onSuccess(result: TotpEnrollmentChallenge) {
// The result is already a TotpEnrollmentChallenge, no cast is needed.
// Show QR code from result.barcodeUri to be scanned by Auth0 Guardian/Verify
// Then use result.id and result.authSession to verify.
}
override fun onFailure(error: MyAccountException) { }
})
```
<details>
<summary>Using Java</summary>

```java
myAccountClient.enrollPushNotification()
.start(new Callback<TotpEnrollmentChallenge, MyAccountException>() {
@Override
public void onSuccess(TotpEnrollmentChallenge result) {
// The result is already a TotpEnrollmentChallenge, no cast is needed.
// Show QR code from result.getBarcodeUri() to be scanned by Auth0 Guardian/Verify
// Then use result.getId() and result.getAuthSession() to verify.
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```
</details>

### Enroll a Recovery Code
**Scopes required:** `create:me:authentication_methods`
```kotlin
myAccountClient.enrollRecoveryCode()
.start(object : Callback<RecoveryCodeEnrollmentChallenge, MyAccountException> {
override fun onSuccess(result: RecoveryCodeEnrollmentChallenge) {
// The result is already a RecoveryCodeEnrollmentChallenge, no cast is needed.
// Display and require the user to save result.recoveryCode
// This method is already verified.
}
override fun onFailure(error: MyAccountException) { }
})

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

```java
myAccountClient.enrollRecoveryCode()
.start(new Callback<RecoveryCodeEnrollmentChallenge, MyAccountException>() {
@Override
public void onSuccess(RecoveryCodeEnrollmentChallenge result) {
// The result is already a RecoveryCodeEnrollmentChallenge, no cast is needed.
// Display and require the user to save result.getRecoveryCode()
// This method is already verified.
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```
</details>

### Verify an Enrollment
**Scopes required:** `create:me:authentication_methods`
```kotlin
// For OTP-based factors (TOTP, Email, Phone)
myAccountClient.verifyOtp("challenge_id_from_enroll", "123456", "auth_session_from_enroll")
.start(object : Callback<AuthenticationMethod, MyAccountException> {
override fun onSuccess(result: AuthenticationMethod) {
// Enrollment successful
}
override fun onFailure(error: MyAccountException) { }
})

// For Push Notification factor
myAccountClient.verify("challenge_id_from_enroll", "auth_session_from_enroll")
.start(object : Callback<AuthenticationMethod, MyAccountException> {
override fun onSuccess(result: AuthenticationMethod) {
// Enrollment successful
}
override fun onFailure(error: MyAccountException) { }
})
```
<details>
<summary>Using Java</summary>

```java
// For OTP-based factors (TOTP, Email, Phone)
myAccountClient.verifyOtp("challenge_id_from_enroll", "123456", "auth_session_from_enroll")
.start(new Callback<AuthenticationMethod, MyAccountException>() {
@Override
public void onSuccess(AuthenticationMethod result) {
// Enrollment successful
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});

// For Push Notification factor
myAccountClient.verify("challenge_id_from_enroll", "auth_session_from_enroll")
.start(new Callback<AuthenticationMethod, MyAccountException>() {
@Override
public void onSuccess(AuthenticationMethod result) {
// Enrollment successful
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```
</details>

### Delete an Authentication Method
**Scopes required:** `delete:me:authentication_methods`
```kotlin
myAccountClient.deleteAuthenticationMethod("phone|dev_...")
.start(object : Callback<Unit, MyAccountException> {
override fun onSuccess(result: Unit) {
// Deletion successful
}
override fun onFailure(error: MyAccountException) { }
})
```
<details>
<summary>Using Java</summary>

```java
myAccountClient.deleteAuthenticationMethod("phone|dev_...")
.start(new Callback<Void, MyAccountException>() {
@Override
public void onSuccess(Void result) {
// Deletion successful
}
@Override
public void onFailure(@NonNull MyAccountException error) { }
});
```
</details>


## Credentials Manager

### Secure Credentials Manager
Expand Down
Loading