aad_b2c_webview 0.0.43 copy "aad_b2c_webview: ^0.0.43" to clipboard
aad_b2c_webview: ^0.0.43 copied to clipboard

A simple Flutter package which embeds weview for accessing Azure AD B2C user flow endpoinr.

Azure AD B2C Embedded Webview #

Azure AD B2C Embedded Webview is a very simple Flutter package that demonstrates how to use the embedded web view to sign in users with Azure AD B2C. Currently, using Flutter packages - appAuth and flutter_azure_b2c redirects to browser and doesn't provide in-app experience.

This package embeds the web view of the user flow endpoint using flutter_appview and redirects the user as per onRedirect callback method.

Features #

Embedded web view for Azure AD B2C for providing in-app experience Redirects to the route specified in redirectRoute after successful sign in Successfully secures the id token or access token in the app using flutter secure storage Navigates to screen in app after successful sign in

Getting started #

To use the package in your Flutter app, add the following code to your main.dart file:

dependencies:
  aad_b2c_webview: <latest_version>

Usage #

Simple In-built Sign In Button #

To add the easy to use sign in with microsoft button simply use the AADLoginButton widget and a beautiful sign in button appears as shown below.

import 'package:aad_b2c_webview/src/login_azure.dart';

class MyLoginPage extends StatelessWidget {
  const MyLoginPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: AADLoginButton(
        userFlowUrl: '<user_flow_endpoint>',
        redirectUrl: '<redirect_url>',
        clientId: '<client_id>',
        onRedirect: (BuildContext context){
          ///Handle navigation to whatever page you choose
          ///Use the build context for navigation
        },
        context: context,
        onAccessToken: (value) {
          ///Store or use access token from here
        },
        onIDToken: (value) {
          ///Store or use ID token from here
        },
        onRefreshToken: (value) {
          ///Store or use refresh token from here
        },
      ),
    );
  }
}

Custom Sign in #

Simply call page direct or use custom build sign in button to call webview page

import 'package:aad_b2c_webview/aad_b2c_webview.dart';

class MyLoginPage extends StatelessWidget {
  const MyLoginPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ADB2CEmbedWebView(
        userFlowUrl: '<user_flow_endpoint>',
        redirectUrl: '<redirect_url>',
        clientId: '<client_id>',
        onRedirect: (BuildContext context){
          ///Handle navigation to whatever page you choose
          ///Use the build context for navigation
        },
        context: context,
        onAccessToken: (value) {
          ///Store or use access token from here
        },
        onIDToken: (value) {
          ///Store or use ID token from here
        },
        onRefreshToken: (value) {
          ///Store or use refresh token from here
        },
      ),
    );
  }
}
18
likes
0
pub points
79%
popularity

Publisher

verified publishermicrosoft.com

A simple Flutter package which embeds weview for accessing Azure AD B2C user flow endpoinr.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

dio, flutter, google_fonts, mockito, pkce, webview_flutter

More

Packages that depend on aad_b2c_webview