login method
Future<Credentials>
login({
- String? audience,
- Set<
String> scopes = const {'openid', 'profile', 'email', 'offline_access'}, - String? redirectUrl,
- String? organizationId,
- String? invitationUrl,
- bool useHTTPS = false,
- CustomTabsOptions? customTabsOptions,
- @Deprecated('Use customTabsOptions instead') List<
String> allowedBrowsers = const [], - bool useEphemeralSession = false,
- Map<
String, String> parameters = const {}, - IdTokenValidationConfig idTokenValidationConfig = const IdTokenValidationConfig(),
- SafariViewController? safariViewController,
- bool useDPoP = false,
Redirects the user to the Auth0 Universal Login page for authentication. If successful, it returns a set of tokens, as well as the user's profile (constructed from ID token claims).
If redirectUrl is not specified, a default URL is used that incorporates
the domain value specified to Auth0.new, and scheme on Android, or
the bundle identifier in iOS/macOS. redirectUrl must appear in your
Allowed Callback URLs list for the Auth0 app.
Read more about redirecting users.
How the ID token is validated can be configured using
idTokenValidationConfig, but in general the defaults for this are
adequate.
Additional notes:
audiencerelates to the API Identifier you want to reference in your access tokens. See API settings to learn more.scopesdefaults toopenid profile email offline_access. You can override these scopes, butopenidis always requested regardless of this setting.- Arbitrary
parameterscan be specified and then picked up in a custom Auth0 Action or Rule. - If you want to log into a specific organization, provide the
organizationId. ProvideinvitationUrlif a user has been invited to join an organization. - (iOS only):
safariViewControllercausesSFSafariViewControllerto be used when opening the Universal Login page, as an alternative to the defaultASWebAuthenticationSession. You will also need to configure your iOS app to automatically resume the Web Auth operation after login. - (iOS/macOS only):
useHTTPScontrols whether to usehttpsas the scheme for the redirect URL on iOS 17.4+ and macOS 14.4+. When set totrue, the bundle identifier of the app will be used as a custom scheme on older versions of iOS and macOS. Requires an Associated Domain configured with thewebcredentialsservice type, set to your Auth0 domain –or custom domain, if you have one. - (iOS/macOS only):
useEphemeralSessioncontrols whether shared persistent storage is used for cookies. Read more on the effects this setting has. - (android only):
customTabsOptionsconfigures Chrome Custom Tabs, including Partial Custom Tabs (bottom sheet / side sheet) on Chrome 107+. See CustomTabsOptions for available settings. - (android only):
allowedBrowsersDefines an allowlist of browser packages. Deprecated: usecustomTabsOptionsinstead. useDPoPenables DPoP for enhanced token security. See README for details. Defaults tofalse.
Implementation
Future<Credentials> login(
{final String? audience,
final Set<String> scopes = const {
'openid',
'profile',
'email',
'offline_access'
},
final String? redirectUrl,
final String? organizationId,
final String? invitationUrl,
final bool useHTTPS = false,
final CustomTabsOptions? customTabsOptions,
@Deprecated('Use customTabsOptions instead')
final List<String> allowedBrowsers = const [],
final bool useEphemeralSession = false,
final Map<String, String> parameters = const {},
final IdTokenValidationConfig idTokenValidationConfig =
const IdTokenValidationConfig(),
final SafariViewController? safariViewController,
final bool useDPoP = false}) async {
final credentials = await Auth0FlutterWebAuthPlatform.instance.login(
_createWebAuthRequest(WebAuthLoginOptions(
audience: audience,
scopes: scopes,
redirectUrl: redirectUrl,
organizationId: organizationId,
invitationUrl: invitationUrl,
parameters: parameters,
idTokenValidationConfig: idTokenValidationConfig,
scheme: _scheme,
useHTTPS: useHTTPS,
useEphemeralSession: useEphemeralSession,
safariViewController: safariViewController,
customTabsOptions: customTabsOptions,
// ignore: deprecated_member_use_from_same_package
allowedBrowsers: allowedBrowsers,
useDPoP: useDPoP)));
await _credentialsManager?.storeCredentials(credentials);
return credentials;
}