MyAccountWeb class

An interface for interacting with the Auth0 My Account API on the web.

This class enables end-users to self-manage their authentication methods (MFA factors) without requiring Management API tokens. It mirrors the mobile MyAccountApi, but is backed by the auth0-spa-js MyAccountApiClient, which requires auth0-spa-js v2.21.1 or later.

Every call is authorized with the access token passed to Auth0Web.myAccount(accessToken:). It must have the audience https://{domain}/me/ and the scopes required by each method. You can obtain one with Auth0Web.getApiCredentials.

Note: When DPoP is enabled (Auth0Web(useDPoP: true)), requests are sent with a DPoP proof signed by this Auth0Web instance's key, so the access token must also have been issued to this same instance.

Failures are reported as a MyAccountException, the same as on mobile.

It is not intended for you to instantiate this class yourself; an instance is available via Auth0Web.myAccount(accessToken:).

Usage example

final auth0 = Auth0Web('DOMAIN', 'CLIENT_ID');

final apiCredentials = await auth0.getApiCredentials(
  audience: 'https://DOMAIN/me/',
  scopes: {'read:me:authentication_methods'},
);
final myAccount = auth0.myAccount(
  accessToken: apiCredentials.accessToken,
);

final methods = await myAccount.getAuthenticationMethods();

Constructors

MyAccountWeb(String _accessToken)

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

confirmEnrollment({required String id, required String authSession, required String factorType}) → Future<AuthenticationMethod>
Confirms an enrollment that does not require a one-time password, namely push notification and recovery code enrollments.
deleteAuthenticationMethod({required String id}) → Future<void>
Deletes an authentication method by id.
enrollEmail({required String email}) → Future<EnrollmentChallenge>
Initiates email enrollment with the specified email address.
enrollPasskey({required PasskeyEnrollmentChallenge challenge, required PasskeyCredential credential}) → Future<MyAccountPasskeyAuthenticationMethod>
Enrolls a new passkey credential. This is the last part of the passkey enrollment flow.
enrollPasskeyChallenge({String? userIdentityId, String? connection}) → Future<PasskeyEnrollmentChallenge>
Requests a challenge for enrolling a new passkey. This is the first part of the passkey enrollment flow.
enrollPhone({required String phoneNumber, required PhoneType type}) → Future<EnrollmentChallenge>
Initiates phone enrollment with the specified phoneNumber and type.
enrollPush() → Future<EnrollmentChallenge>
Initiates push notification enrollment.
enrollRecoveryCode() → Future<EnrollmentChallenge>
Initiates recovery code enrollment.
enrollTotp() → Future<EnrollmentChallenge>
Initiates TOTP (authenticator app) enrollment.
getAuthenticationMethod({required String id}) → Future<AuthenticationMethod>
Gets a specific authentication method by id.
getAuthenticationMethods({AuthenticationMethodType? type}) → Future<List<AuthenticationMethod>>
Lists all authentication methods enrolled by the user.
getFactors() → Future<List<Factor>>
Lists the factors available for enrollment on the tenant.
getUserProfile({List<String>? fields, bool includeFields = true}) → Future<MyAccountProfile>
Retrieves the current user's profile, including a MyAccountProfile.profilePolicy descriptor for each field that tells whether it can be edited by the user and why.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
updateAuthenticationMethod({required String id, String? name, PhoneType? preferredAuthenticationMethod}) → Future<AuthenticationMethod>
Updates an existing authentication method identified by id.
updateUserProfile({String? givenName, String? familyName, String? name, String? nickname, String? picture}) → Future<MyAccountProfile>
Updates the current user's editable profile fields, and returns the full, updated MyAccountProfile.
verifyOtp({required String id, required String authSession, required String otp, required String factorType}) → Future<AuthenticationMethod>
Verifies an enrollment using a one-time password otp.

Operators

operator ==(Object other) → bool
The equality operator.
inherited