AuthenticationApi class

An interface for calling some of the endpoints in Auth0's Authentication API.

This class presents building blocks for doing more fine-grained authentication with Auth0 using Username and Password login. Unlike WebAuthentication, these do not use Auth0 Universal Login (the recommended way of doing authentication), and thus users are not redirected to Auth0 for authentication.

It is not intended for you to instantiate this class yourself, as an instance of it is already exposed as Auth0.api.

Usage example:

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

final result = await auth0.api.login({
  usernameOrEmail: 'my@email.com',
  password: 'my_password'
  connectionOrRealm: 'Username-Password-Authentication'
})

final accessToken = result.accessToken;

Constructors

AuthenticationApi(Account _account, UserAgent _userAgent)

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

login({required String usernameOrEmail, required String password, required String connectionOrRealm, String? audience, Set<String> scopes = const {'openid', 'profile', 'email', 'offline_access'}, Map<String, String> parameters = const {}}) Future<Credentials>
Authenticates the user using a usernameOrEmail and a password, with the specified connectionOrRealm. If successful, it returns a set of tokens, as well as the user's profile (constructed from ID token claims).
loginWithOtp({required String otp, required String mfaToken}) Future<Credentials>
Authenticates the user using a mfaToken and an otp, after login returned with an ApiException with ApiException.isMultifactorRequired set to true. If successful, it returns a set of tokens, as well as the user's profile (constructed from ID token claims).
multifactorChallenge({required String mfaToken, List<ChallengeType>? types, String? authenticatorId}) Future<Challenge>
Requests a challenge for multi-factor authentication (MFA) based on the challenge types supported by the app and user.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
renewCredentials({required String refreshToken, Set<String> scopes = const {}, Map<String, String> parameters = const {}}) Future<Credentials>
Uses a refreshToken to get a new access token.
resetPassword({required String email, required String connection, Map<String, String> parameters = const {}}) Future<void>
Initiates a reset of password of the user with the specific email address in the specific connection.
signup({required String email, required String password, String? username, required String connection, Map<String, String> userMetadata = const {}, Map<String, String> parameters = const {}}) Future<DatabaseUser>
Registers a new user with the specified email address and password in the specified connection.
toString() String
A string representation of this object.
inherited
userProfile({required String accessToken, Map<String, String> parameters = const {}}) Future<UserProfile>
Fetches the user's profile from the /userinfo endpoint. An accessToken from a successful authentication call must be supplied.

Operators

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