logout method

Future<void> logout({
  1. String? returnTo,
  2. bool useHTTPS = false,
  3. CustomTabsOptions? customTabsOptions,
  4. @Deprecated('Use customTabsOptions instead') List<String> allowedBrowsers = const [],
  5. 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): customTabsOptions configures Chrome Custom Tabs, including Partial Custom Tabs (bottom sheet / side sheet) on Chrome 107+.
  • (android only): allowedBrowsers Defines an allowlist of browser packages. Deprecated: use customTabsOptions instead.

Implementation

Future<void> logout(
    {final String? returnTo,
    final bool useHTTPS = false,
    final CustomTabsOptions? customTabsOptions,
    @Deprecated('Use customTabsOptions instead')
    final List<String> allowedBrowsers = const [],
    final bool federated = false}) async {
  await Auth0FlutterWebAuthPlatform.instance.logout(_createWebAuthRequest(
    WebAuthLogoutOptions(
        returnTo: returnTo,
        scheme: _scheme,
        useHTTPS: useHTTPS,
        federated: federated,
        customTabsOptions: customTabsOptions,
        // ignore: deprecated_member_use_from_same_package
        allowedBrowsers: allowedBrowsers),
  ));
  await _credentialsManager?.clearCredentials();
}