logout method

Future<void> logout({
  1. String? returnTo,
  2. bool useHTTPS = false,
  3. List<String> allowedBrowsers = const [],
  4. bool federated = false,
})

Redirects the user to the Auth0 Logout endpoint to remove their authentication session, and log out. The user is immediately redirected back to the application once logout is complete.

If returnTo is not specified, a default URL is used that incorporates the domain value specified to Auth0.new, and the custom scheme on Android, or the bundle identifier on iOS/macOS. returnTo must appear in your Allowed Logout URLs list for the Auth0 app. Read more about redirecting users after logout.

useHTTPS (iOS/macOS only) controls whether to use https as the scheme for the return URL on iOS 17.4+ and macOS 14.4+. When set to true, 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 the webcredentials service type, set to your Auth0 domain –or custom domain, if you have one.

  • (android only): allowedBrowsers Defines an allowlist of browser packages When the user's default browser is in the allowlist, it uses the default browser When the user's default browser is not in the allowlist, but the user has another allowed browser installed, the allowed browser is used instead When the user's default browser is not in the allowlist, and the user has no other allowed browser installed, an error is returned

Implementation

Future<void> logout(
    {final String? returnTo,
    final bool useHTTPS = false,
    final List<String> allowedBrowsers = const [],
    final bool federated = false}) async {
  await Auth0FlutterWebAuthPlatform.instance.logout(_createWebAuthRequest(
    WebAuthLogoutOptions(
        returnTo: returnTo,
        scheme: _scheme,
        useHTTPS: useHTTPS,
        federated: federated,
        allowedBrowsers: allowedBrowsers),
  ));
  await _credentialsManager?.clearCredentials();
}