onLoad method

Future<Credentials?> onLoad({
  1. int? authorizeTimeoutInSeconds,
  2. CacheLocation? cacheLocation,
  3. String? cookieDomain,
  4. int? httpTimeoutInSeconds,
  5. String? issuer,
  6. int? leeway,
  7. bool? useLegacySameSiteCookie,
  8. int? sessionCheckExpiryInDays,
  9. bool? useCookiesForTransactions,
  10. bool? useFormData,
  11. bool? useRefreshTokens,
  12. bool? useRefreshTokensFallback,
  13. String? audience,
  14. Set<String>? scopes,
  15. Map<String, String> parameters = const {},

Initializes the client.

This should be called during the loading phase of your application. If the current user already has a session with Auth0, an instance of Credentials will be returned, populated with their user data and tokens.

Additional notes:

  • You can specify custom leeway and issuer values to be used for the validation of the ID token. See the IdTokenValidationConfig type to learn more about these parameters.
  • See the ClientOptions type for the full description of the remaining parameters for this method.
  • 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. You can override these scopes, but openid is always requested regardless of this setting.


Future<Credentials?> onLoad(
    {final int? authorizeTimeoutInSeconds,
    final CacheLocation? cacheLocation,
    final String? cookieDomain,
    final int? httpTimeoutInSeconds,
    final String? issuer,
    final int? leeway,
    final bool? useLegacySameSiteCookie,
    final int? sessionCheckExpiryInDays,
    final bool? useCookiesForTransactions,
    final bool? useFormData,
    final bool? useRefreshTokens,
    final bool? useRefreshTokensFallback,
    final String? audience,
    final Set<String>? scopes,
    final Map<String, String> parameters = const {}}) async {
  await Auth0FlutterWebPlatform.instance.initialize(
          account: _account,
          authorizeTimeoutInSeconds: authorizeTimeoutInSeconds,
          cacheLocation: cacheLocation,
          cookieDomain: cookieDomain,
          httpTimeoutInSeconds: httpTimeoutInSeconds,
              IdTokenValidationConfig(issuer: issuer, leeway: leeway),
          useLegacySameSiteCookie: useLegacySameSiteCookie,
          sessionCheckExpiryInDays: sessionCheckExpiryInDays,
          useCookiesForTransactions: useCookiesForTransactions,
          useFormData: useFormData,
          useRefreshTokens: useRefreshTokens,
          useRefreshTokensFallback: useRefreshTokensFallback,
          audience: audience,
          scopes: scopes,
          parameters: parameters),

  if (await hasValidCredentials()) {
    return credentials();

  return null;