login method
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).
If using the default username and password database connection,
connectionOrRealm
should be set to Username-Password-Authentication
.
Endpoint
https://auth0.com/docs/api/authentication#login
Notes
audience
relates to the API Identifier you want to reference in your access tokens. See API settings to learn more.scopes
defaults toopenid profile email offline_access
. You can override these scopes, butopenid
is always requested regardless of this setting.parameters
can be used to sent through custom parameters to the endpoint to be picked up in a Rule or Action.
Usage example
final result = await auth0.api.login({
usernameOrEmail: 'my@email.com',
password: 'my_password'
connectionOrRealm: 'Username-Password-Authentication'
});
Implementation
Future<Credentials> login({
required final String usernameOrEmail,
required final String password,
required final String connectionOrRealm,
final String? audience,
final Set<String> scopes = const {
'openid',
'profile',
'email',
'offline_access'
},
final Map<String, String> parameters = const {},
}) =>
Auth0FlutterAuthPlatform.instance
.login(_createApiRequest(AuthLoginOptions(
usernameOrEmail: usernameOrEmail,
password: password,
connectionOrRealm: connectionOrRealm,
audience: audience,
scopes: scopes,
parameters: parameters,
)));