login method

Future<Credentials> login({
  1. required String usernameOrEmail,
  2. required String password,
  3. required String connectionOrRealm,
  4. String? audience,
  5. Set<String> scopes = const {'openid', 'profile', 'email', 'offline_access'},
  6. Map<String, String> parameters = const {},

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.




  • audience relates to the API Identifier you want to reference in your access tokens. See API settings to learn more.
  • scopes defaults to openid profile email offline_access. You can override these scopes, but openid 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'


Future<Credentials> login({
  required final String usernameOrEmail,
  required final String password,
  required final String connectionOrRealm,
  final String? audience,
  final Set<String> scopes = const {
  final Map<String, String> parameters = const {},
}) =>
      usernameOrEmail: usernameOrEmail,
      password: password,
      connectionOrRealm: connectionOrRealm,
      audience: audience,
      scopes: scopes,
      parameters: parameters,