GithubHelp home page GithubHelp logo

mohanajuhi166 / aad-b2c-webview Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 295 KB

AAD b2c Webview

License: Other

Kotlin 0.21% Ruby 4.65% Swift 2.27% Objective-C 0.07% Dart 17.45% CMake 32.49% C++ 37.23% C 2.47% HTML 3.15%

aad-b2c-webview's Introduction

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

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: ^0.0.1

Usage

Example added in aad-b2c-webview/aad_b2c folder

@override
Widget build(BuildContext context) {
  return MaterialApp(
    title: 'Flutter Demo',
    theme: ThemeData(
      primaryColor: const Color(0xFF2F56D2),
      textTheme: const TextTheme(
        headlineLarge: TextStyle(
          color: Colors.black,
          fontSize: 32,
          fontWeight: FontWeight.w700,
          fontFamily: 'UberMove',
        ),
        bodyText1: TextStyle(
          color: Color(0xFF8A8A8A),
          fontSize: 17,
          fontWeight: FontWeight.w400,
          fontFamily: 'UberMoveText',
        ),
        headline2: TextStyle(
          fontSize: 18,
          color: Colors.black,
          fontWeight: FontWeight.w700,
          fontFamily: 'UberMove',
        ),
      ),
    ),
    debugShowCheckedModeBanner: false,
    initialRoute: '/',
    routes: {
      // When navigating to the "/" route, build the Create Account widget.

      '/': (context) =>
      const ADB2CEmbedWebView(
        url: '<user_flow_endpoint>',
        clientId: '<client_id_of_user_flow>',
        redirectUrl: '<redirect_uri_of_user_flow>',
        appRedirectRoute: '<route_to_redirect_to_after_sign_in>',
        onRedirect: onRedirect,
      ),
    },
  );
}

Parameters Used In ADB2CEmbedWebView

  • url: This is the user flow/policy endpoint

  • clientId: This is client id of the application used for redirection within user flow

  • redirectUrl: This is redirect Url of the application used for redirection within user flow

  • appRedirectRoute: This is the in-app route to navigate to, after successful sign in on redirect

  • onRedirect: This is the callback method to handle the redirect url. This method is called when the redirect url is hit. This method should return the route to navigate to after successful sign in.

aad-b2c-webview's People

Contributors

mohanajuhi166 avatar

Stargazers

 avatar Brad avatar Nnacheta Chimdike avatar Abhishek Kumar Singh avatar

Watchers

 avatar

Forkers

jspersonal

aad-b2c-webview's Issues

Incorrect scope used when requesting access tokens

Hello,

I'm currently utilizing this library in a project and I've encountered an issue where the access token is not being received.

When the library opens the sign-in page, it correctly uses the scopes I provide. However, in the getAllTokens function, the scopes are hardcoded to openid and offline_access rather than utilizing the scopes that were passed in.

This is the current implementation in the getAllTokens function:

Future<AzureTokenResponse?> getAllTokens({
...
String scopes = Constants.defaultScopes, //problem is here
...
}) async {
//...
}

Since the scope constant to 'openid profile offline_access', the library only fetches id_token and refresh_token but not the access_token.

The scope parameter in the post request data should be set to the scope provided, which can be done by passing it as a parameter to the getAllTokens function. If no scope is provided, then it can default to 'openid offline_access'.

Thank you for your attention to this issue. Please let me know if any more information is needed.

Redirect Uri is not working

When I click the "AD sign-in" button I am getting "ERR: UNKNOWN_URL_SCHEME" and the actual error is aadb2c90006 - "The redirect URI provided in the request is not registered for the client id".

Here are the steps to reproduce the issue:

  1. Created a tenant in Azure Portal
  2. Registered the app
  3. Added redirect URI for Android which has the following structure: msauth://com.companyname.appname/my-hash-code
  4. Added the below activity block in my AndroidManifest.xml
  5. Implemented the sample for aad_b2c_webview
<activity
    android:exported="true"
    android:name="com.microsoft.identity.client.BrowserTabActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="msauth"
            android:host="com.companyname.appname"
            android:path="/my-hash-code" />
    </intent-filter>
</activity>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.