auth0_spa_dart 1.0.2 copy "auth0_spa_dart: ^1.0.2" to clipboard
auth0_spa_dart: ^1.0.2 copied to clipboard

Platformweb

A dart wrapper for auth0-spa-js

Auth0-SPA-Dart #

https://pub.dev/packages/auth0_spa_dart

Features #

Dart wrapper for auth0-spa-js

Getting started #

Add the following to your index.html:

<script src="https://cdn.auth0.com/js/auth0-spa-js/1.19/auth0-spa-js.production.js"></script>

Usage #

Create client:

  final client = await createAuth0Client(
      clientId: clientId,
      domain: domain,
      useRefreshTokens: true, // default = false
      cacheLocation: "localstorage" // default = "memory"
  );

Use "localstorage" for cacheLocation to persist tokens across refreshes and sessions.

Launch login popup:

  await client.loginWithPopup();

Login with redirect:

await client.loginWithRedirect();

Get token:

  final token = await client.getTokenSilently(
    detailedResponse: true // default = false.
  );

If detailedResponse is false, it returns only the accessToken as a string. Otherwise, it returns:

{
  "id_token": "...",
  "access_token": "...",
  "expires_in": "..."
}

Check if authenticated:

await client.isAuthenticated();

Contributing #

Feel free contribute. This project is still in its infancy, so it will be informal unless it takes off.

3
likes
90
pub points
17%
popularity

Publisher

unverified uploader

A dart wrapper for auth0-spa-js

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

js

More

Packages that depend on auth0_spa_dart