auth0_web_auth 1.0.1 copy "auth0_web_auth: ^1.0.1" to clipboard
auth0_web_auth: ^1.0.1 copied to clipboard

Platformweb

This package provides a Dart wrapper around the auth0-spa-js library, making the Auth0 authentication available on Flutter Web.

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 #

  • Add the auth0-spa-js JavaScript file to web/index.html, in the HEAD section.
<!DOCTYPE html>
<html>
<head>
  <!-- Other head content ... -->

  <script src="https://cdn.auth0.com/js/auth0-spa-js/1.22.2/auth0-spa-js.development.js"></script>
</head>
<body>
  <!-- Other body content ... -->
</body>
</html>
  • Use the package in your app
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.

0
likes
120
points
63
downloads

Publisher

unverified uploader

Weekly Downloads

This package provides a Dart wrapper around the auth0-spa-js library, making the Auth0 authentication available on Flutter Web.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, js, universal_html

More

Packages that depend on auth0_web_auth