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

Flutter package for handling authentication using **Azure Active Directory B2C**, supporting **Facebook**, **Google**, **Email/Password**, and **Phone** sign-in through Azure's identity providers.

example/lib/main.dart

import 'dart:async';

import 'package:app_links/app_links.dart';
import 'package:azure_auth/features/auth/cubit/auth_cubit.dart';
import 'package:azure_auth/login_screen.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); // β›” removes status bar

  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final AppLinks _appLinks = AppLinks();
  StreamSubscription<Uri>? _linkSubscription;
  late final AuthCubit _authCubit; // πŸ‘ˆ make it accessible

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _authCubit = AuthCubit(
      // πŸ‘ˆ initialize it here
      clientId: "54e95ff1-187c-4c38-89b5-d1796c495054",
      redirectUri: "com.example.vastu://vsauth",
      scope:
          "openid profile email offline_access https://astroconnect.onmicrosoft.com/54e95ff1-187c-4c38-89b5-d1796c495054/scope_vs_auth_test",
    );
    initDeepLinks();
  }

  Future<void> initDeepLinks() async {
    CupertinoActivityIndicator(animating: true);
    // Handle links
    _linkSubscription = AppLinks().uriLinkStream.listen((uri) async {
      debugPrint('onAppLink: $uri');
      Uri.parse(uri.toString());
      if (uri.toString().contains('vsauth/?code')) {
        // handle navigation and otherthings
        Map<String, dynamic>? userData = await _authCubit?.getAuthrorisationCode(uri);
        debugPrint("User data is in main project ${userData}");
        CupertinoActivityIndicator(animating: false);
      }
      //openAppLink(uri);
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // TRY THIS: Try running your application with "flutter run". You'll see
        // the application has a purple toolbar. Then, without quitting the app,
        // try changing the seedColor in the colorScheme below to Colors.green
        // and then invoke "hot reload" (save your changes or press the "hot
        // reload" button in a Flutter-supported IDE, or press "r" if you used
        // the command line to start the app).
        //
        // Notice that the counter didn't reset back to zero; the application
        // state is not lost during the reload. To reset the state, use hot
        // restart instead.
        //
        // This works for code too, not just values: Most code changes can be
        // tested with just a hot reload.
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: AuthScreen(
        authCubit: _authCubit,
        onLoginSuccess: () {},
        fb_flowName: "'B2C_1_vs_facebook_test'",
        google_flowName: "B2C_1_vs_google_test",
        email_phone_flowName: "B2C_1_email_phone_vs_auth",
      ),
    );
  }
}
1
likes
110
points
118
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter package for handling authentication using **Azure Active Directory B2C**, supporting **Facebook**, **Google**, **Email/Password**, and **Phone** sign-in through Azure's identity providers.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

app_links, auto_route, dart_jsonwebtoken, dio, flutter, flutter_bloc, flutter_secure_storage, flutter_svg, flutter_web_auth_2, form_validator, get, google_fonts, json_serializable

More

Packages that depend on azure_auth