onLoad method
Future<Credentials?>
onLoad({
- int? authorizeTimeoutInSeconds,
- CacheLocation? cacheLocation,
- String? cookieDomain,
- int? httpTimeoutInSeconds,
- String? issuer,
- int? leeway,
- bool? useLegacySameSiteCookie,
- int? sessionCheckExpiryInDays,
- bool? useCookiesForTransactions,
- bool? useFormData,
- bool? useRefreshTokens,
- bool? useRefreshTokensFallback,
- bool? useMrrt,
- String? audience,
- Set<
String> ? scopes, - 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
leewayandissuervalues to be used for the validation of the ID token. See the IdTokenValidationConfig type to learn more about these parameters. - See the
ClientOptionstype for the full description of the remaining parameters for this method. audiencerelates to the API Identifier you want to reference in your access tokens. See API settings to learn more.scopesdefaults toopenid profile email. You can override these scopes, butopenidis always requested regardless of this setting.useMrrtenables Multi-Resource Refresh Tokens, allowing a single refresh token to be reused to obtain access tokens for multiple APIs (audiences). Once enabled, request per-audience tokens via getApiCredentials. Enabling this forcesuseRefreshTokenson (even if it was explicitly set tofalse), and requires MRRT to be enabled on your Auth0 tenant.
Implementation
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 bool? useMrrt,
final String? audience,
final Set<String>? scopes,
final Map<String, String> parameters = const {}}) async {
await Auth0FlutterWebPlatform.instance.initialize(
ClientOptions(
account: _account,
useDPoP: _useDPoP,
authorizeTimeoutInSeconds: authorizeTimeoutInSeconds,
cacheLocation: cacheLocation ?? _cacheLocation,
cookieDomain: cookieDomain,
httpTimeoutInSeconds: httpTimeoutInSeconds,
idTokenValidationConfig:
IdTokenValidationConfig(issuer: issuer, leeway: leeway),
useLegacySameSiteCookie: useLegacySameSiteCookie,
sessionCheckExpiryInDays: sessionCheckExpiryInDays,
useCookiesForTransactions: useCookiesForTransactions,
useFormData: useFormData,
useRefreshTokens: useRefreshTokens,
useRefreshTokensFallback: useRefreshTokensFallback,
useMrrt: useMrrt,
audience: audience,
scopes: scopes,
parameters: {
if (_redirectUrl != null) 'redirect_uri': _redirectUrl,
...parameters
}),
_userAgent);
if (await hasValidCredentials()) {
return credentials();
}
return null;
}