djangoflow_auth 0.5.0+1 copy "djangoflow_auth: ^0.5.0+1" to clipboard
djangoflow_auth: ^0.5.0+1 copied to clipboard

djangoflow_auth is your ultimate Flutter authentication companion, packed with Djangoflow API supports.

DjangoFlow Auth Google Package Logo

🌟 DjangoFlow Auth Flutter Package 🌟

GitHub Repository Pub Package

djangoflow_auth is your ultimate Flutter authentication companion! Seamlessly integrate authentication functionalities compatible with django-df-auth. Supports multiple providers, OTP login/signup, and more, making user authentication a breeze for your Flutter app. Yes, it's ready out of the box! 🔒

NOTE: This package relies on djangoflow_openapi for models and API methods. Make sure you're using the DjangoFlow framework for development. For Django backend with DjangoFlow authentication, follow the django-df-auth README. Checkout our Example 🚀

🚀 Features 🚀

  • Seamless integration with django-df-auth.
  • Support for multiple authentication providers, including Google, Facebook, Apple Sign-In, Discord, and more.
  • Built on top of popular and well-maintained Flutter packages like bloc, dio, and hydrated_bloc, etc.
  • Supports OTP, magic link, Google, Facebook, Apple, Discord for Flutter web and mobile platforms out of the box.
  • Supports OAuth2 web support with WebWindow popup.

📑 Table of Contents 📑

📦 Installation 📦

Add the djangoflow_auth package to your pubspec.yaml file:

  djangoflow_auth: <lastest_version>

      ref: master

Run flutter pub get to fetch the package.

🔧 Social Login Configuration 🔧

This package has built-in support for the following social logins:
  • Google: djangoflow_auth_google
  • Facebook: djangoflow_auth_facebook
  • Apple: djangoflow_auth_apple
  • Discord: djangoflow_auth_discord
  • Twitter: Coming soon...

If you want to create your custom SocialLogin, you can extend the SocialLogin class. Here's an example from the djangoflow_auth_google package's implementation:

class GoogleSocialLogin extends SocialLogin<GoogleSignInAccount> {
  final GoogleSignIn googleSignIn;

  GoogleSocialLogin({required this.googleSignIn})
      : super(type: SocialLoginType.fromProvider(ProviderEnum.googleOauth2));

  Future<GoogleSignInAccount?> login() async {
    final result = await googleSignIn.signIn();
    return result;

  Future<void> logout() async {
    if (await googleSignIn.isSignedIn()) {
      await googleSignIn.disconnect();

💡 Usage 💡

Setting up AuthCubit #

- Import the necessary packages, for example using BlocProvider:
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:djangoflow_auth/djangoflow_auth.dart';
import 'package:djangoflow_auth_google/djangoflow_auth.dart_google';
import 'package:google_sign_in/google_sign_in.dart';
- Initialize `AuthCubit` and provide social login providers via `BlocProvider`
void main() {
        create: (context) => AuthCubit.instance
            ..authApi = {Your AuthApi, comes from djangoflow_openapi}
            ..socialLogins = [
                type: SocialLoginType.fromProvider(
                googleSignIn: GoogleSignIn(
                  scopes: [
            // Add other social login providers
        child: MyApp(),

Performing OTP Login #

Inside your app, use the AuthCubit to perform OTP login:

final authCubit =<AuthCubit>();

try {
  // Step 1: Request OTP for the user's email
  await authCubit.requestOTP(email: userEmail);

  // Step 2: Present the OTP input UI to the user and retrieve the OTP value

  // Step 3: Initiate OTP login
  await authCubit.loginWithEmailOTP(email: userEmail, otp: enteredOTP);

  // Step 4: Handle successful login and proceed with app navigation
} catch (error) {
  // Handle errors, e.g., display an error message to the user

Inside your app, use the AuthCubit to perform login with a Magic Link:

final authCubit =<AuthCubit>();

try {
  // Step 1: Retrieve the magic link from your user's source (e.g., email + otp) in base64
  final magicLink = "your_encoded_magic_link_here"; // Replace with the actual magic link

  // Step 2: Initiate login with the user's email and OTP
  await authCubit.loginWithMagicLink(magicLink: magicLink);

  // Step 3: Handle successful login and proceed with app navigation
} catch (error) {
  // Handle errors, e.g., display an error message to the user

Performing Social Authentications #

Let's say we are going to login via google, inside your app, initiate social login using AuthCubit methods

  • Add the djangoflow_auth_google package to your pubspec.yaml file:

      djangoflow_auth_google: <latest_version>
      google_sign_in: <latest_version>

    and run flutter pub get

  • Then when you need to authenticate with Google sign in,

    final authCubit =<AuthCubit>();
    final socialLogin =
    // Authenticate with Google
    final result =
        await authCubit.requestTokenFromSocialProvider<

Handling Social Login Results #

Based on the login result, retrieve the access token and use it to log in with the social provider:

if (result == null) {
  throw Exception('Google Sign In failed');
} else {
  final googleSignInAuthentication =
      await result.authentication;
  final accessToken =

  if (accessToken == null) {
    throw Exception(
        'Google Sign In failed - no token');
  await authCubit.loginWithSocialProvider(
      provider: socialLogin.type.provider,
      accessToken: accessToken,

🌟 Example 🌟


👏 Contributions and Issues 👏

Contributions, bug reports, and feature requests are welcome! Feel free to submit a pull request or open an issue on the GitHub repository.

📄 License 📄

This package is distributed under the MIT License.

pub points



djangoflow_auth is your ultimate Flutter authentication companion, packed with Djangoflow API supports.

Repository (GitHub)
View/report issues


API reference


MIT (license)


bloc, collection, dio, djangoflow_openapi, flutter, freezed_annotation, hydrated_bloc, universal_html, uuid


Packages that depend on djangoflow_auth