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,
- 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
leeway
andissuer
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 toopenid profile email
. You can override these scopes, butopenid
is always requested regardless of this setting.
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 String? audience,
final Set<String>? scopes,
final Map<String, String> parameters = const {}}) async {
await Auth0FlutterWebPlatform.instance.initialize(
ClientOptions(
account: _account,
authorizeTimeoutInSeconds: authorizeTimeoutInSeconds,
cacheLocation: cacheLocation,
cookieDomain: cookieDomain,
httpTimeoutInSeconds: httpTimeoutInSeconds,
idTokenValidationConfig:
IdTokenValidationConfig(issuer: issuer, leeway: leeway),
useLegacySameSiteCookie: useLegacySameSiteCookie,
sessionCheckExpiryInDays: sessionCheckExpiryInDays,
useCookiesForTransactions: useCookiesForTransactions,
useFormData: useFormData,
useRefreshTokens: useRefreshTokens,
useRefreshTokensFallback: useRefreshTokensFallback,
audience: audience,
scopes: scopes,
parameters: parameters),
_userAgent);
if (await hasValidCredentials()) {
return credentials();
}
return null;
}