auth0_flutter2 0.0.16 copy "auth0_flutter2: ^0.0.16" to clipboard
auth0_flutter2: ^0.0.16 copied to clipboard

Cross-platform Auth0 authentication integration, in minutes, for mobile and web.

A Flutter package to easily integrate Auth0 into Android, iOS, and Web Flutter apps.

Platform Support #

Android iOS MacOS Web Linux Windows
✔️ ✔️ x ✔️ x x

Auth0Flutter2 is not supported on MacOS, Windows, or Linux.

Features #

Integrate Auth0 authentication across mobile and web Flutter apps. Login users, logout users, and identify currently authenticated users across web and mobile.

Usage #

To use this plugin, add auth0_flutter2 as a dependency in your pubspec.yaml file.

iOS and Android #

Follow the iOS and Android usage instructions in the official Auth0 mobile package

Web #

Add the Auth0 Javascript SPA (Single Page Application) library.

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

In main.dart, add a method to handle Web login callbacks.

  @override
  void initState() {
    checkForRedirectCallback();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    .....
  }

  Future<void> checkForRedirectCallback() async {
    // Check for login callback state.
    var redirectCallbackHandled =
        await Auth0Flutter2.instance.handleWebLoginCallback(
      Uri.base.toString(),
    );

    // If callback was able to be processed, do something.
    if (redirectCallbackHandled) {
      // DO SOMETHING...
    }
  }

Example #

Import the library.

import 'package:auth0_flutter2/auth0_flutter2.dart';

Then initialize the Auth0Flutter2 class in your main() method.

void main() {
  Auth0Flutter2.auth0Domain = "AUTH0_DOMAIN";
  Auth0Flutter2.auth0ClientId = "AUTH0_CLIENT_ID";
  Auth0Flutter2.redirectUri = "YOUR_APP_REDIRECT_URI";

  // Set the URL strategy for our web app. Removes 
  // trailing hash(#) to ensure login callbacks
  // will be captured and processed correctly.
  Auth0Flutter2.setPathUrlStrategy();

  runApp(const MyApp());
}

Then invoke the class methods anywhere in your Dart code.

Auth0Flutter2.instance.loginUser();
Auth0Flutter2.instance.logoutUser();
Auth0Flutter2.instance.getLoggedInUserId();

For The Love Of Open Source. #

Buy Me A Coffee

10
likes
130
pub points
27%
popularity

Publisher

unverified uploader

Cross-platform Auth0 authentication integration, in minutes, for mobile and web.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

auth0_flutter, flutter, js, meta, universal_html, url_strategy

More

Packages that depend on auth0_flutter2