-
Notifications
You must be signed in to change notification settings - Fork 170
SDK-6103 Added support for My Account API. #847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
c8243e3
58ebd47
c0703ad
a702900
13da6ba
c42e67f
eddddc0
25b4e13
6ae1fe1
93c507b
5a71404
db02f71
bb3adc3
4689ff3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
|
|
@@ -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: EnrollmentChallenge) { | ||
| val totpChallenge = result as TotpEnrollmentChallenge | ||
| // Show QR code from totpChallenge.barcodeUri or manual code from totpChallenge.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(EnrollmentChallenge result) { | ||
| TotpEnrollmentChallenge totpChallenge = (TotpEnrollmentChallenge) result; | ||
| // Show QR code from totpChallenge.getBarcodeUri() or manual code from totpChallenge.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: EnrollmentChallenge) { | ||
| val pushChallenge = result as TotpEnrollmentChallenge // Uses the same response format as TOTP | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Necessary changes in line 1142 and 1143
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| // Show QR code from pushChallenge.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(EnrollmentChallenge result) { | ||
| TotpEnrollmentChallenge pushChallenge = (TotpEnrollmentChallenge) result; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes in line 1157 and 1158
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| // Show QR code from pushChallenge.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: EnrollmentChallenge) { | ||
| val recoveryChallenge = result as RecoveryCodeEnrollmentChallenge | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why can't we return an instance of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes in line 1173 and 1174
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| // Display and require the user to save recoveryChallenge.recoveryCode | ||
| // This method is already verified. | ||
| } | ||
| override fun onFailure(error: MyAccountException) { } | ||
| }) | ||
|
|
||
| ``` | ||
| <details> | ||
| <summary>Using Java</summary> | ||
|
|
||
| ```java | ||
| myAccountClient.enrollRecoveryCode() | ||
| .start(new Callback<EnrollmentChallenge, MyAccountException>() { | ||
| @Override | ||
| public void onSuccess(RecoveryCodeEnrollmentChallenge result) { | ||
| RecoveryCodeEnrollmentChallenge recoveryChallenge = (RecoveryCodeEnrollmentChallenge) result; | ||
| // Display and require the user to save recoveryChallenge.getRecoveryCode() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes in line 1190
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| // 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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do the users need to explicitly cast them to TotpEnrollmentChallenge ? Why can't we return an instance of
TotpEnrollmentChallenge?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to make the necessary changes in line 1112 and 1113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done