This package is a Dart wrapper around the official auth0-spa-js JavaScript package. It enables adding Auth0 authentication to Flutter Web Apps without writing a standalone authentication library in Dart.

Features

  • Authentication with Auth0 using PKCE
  • Securing the app with Refresh Tokens
  • Use the returned access token to access a protected resource (eg. backend server)

Usage

var auth0client = await Auth0.create(Auth0ClientOptions(
  domain: example-domain.eu.auth0.com, // Your domain
  clientId: asdfgh123456, // Your client id
  redirectUri: http://example.com, // Your redirect URI
  audience: https://example/api, // Your audience
  useRefreshTokens: true, // Use refresh tokens instead of cookie-based validation
  cacheLocation: 'localstorage' // Store the tokens in local storage, default is in-memory
));

auth0client.loginWithRedirect(
  RedirectLoginOptions(uiLocales: locale ?? languageCode)
);

_client.handleRedirectCallbackWithQuery('query');

Additional information

Feel free to contribute to the package and file bug reports on the official repository.

Libraries

auth0_web_auth
Support for doing something awesome.