flutter_microsoft_authentication 0.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

Getting Started #

import 'package:flutter_microsoft_authentication/flutter_microsoft_authentication.dart';
FlutterMicrosoftAuthentication fma = FlutterMicrosoftAuthentication(
  kClientID: "<client-id>",
  kAuthority: "https://login.microsoftonline.com/organizations",
  kScopes: ["User.Read", "User.ReadBasic.All"],
  androidConfigAssetPath: "assets/auth_config.json" // Android MSAL Config file

// Sign in interactively
String authToken = await this.fma.acquireTokenInteractively;

// Sign in silently
String authToken = await this.fma.acquireTokenSilently;

// Sign out
await this.fma.signOut;

// Android load account username
await this.fma.loadAccount;

Flutter #

Import the Flutter Microsoft Authentication package into your flutter application by adding it to the list of dependencies in your pubsec.yaml file.

  flutter_microsoft_authentication: ^0.0.4

Configuring MSAL for Android #

Getting StartedLibraryAPI ReferenceSupport
  1. Register your app
  • Create App Registration in Azure Portal
  • In Authentication, add Android platform and fill in your bundle id
  • Make note of the MSAL Configuration
  1. Add BrowserTabActivity with RedirectUri to Android Manifest.xml
<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
            android:path="/[Signature Hash]"
            android:scheme="msauth" />
  1. Create Msal Configuration JSON file
  "client_id": "<client id>",
  "authorization_user_agent": "DEFAULT",
  "redirect_uri": "<redirect uri>",
  "account_mode": "SINGLE",
  "broker_redirect_uri_registered": true,
  "shared_device_mode_supported": true,
  "authorities": [
      "type": "<type>",
      "audience": {
        "type": "<type>",
        "tenant_id": "<tenant id>"
  1. Add android MSAL config file to pubspec.yaml assets
    - assets/auth_config.json

Configuring MSAL for iOS #

Library: https://github.com/AzureAD/microsoft-authentication-library-for-objc

  1. Register your app
  • Create App Registration in Azure Portal
  • In Authentication, add iOS platform and fill in your bundle id
  • Make note of the MSAL Configuration
  1. Add Keychain Sharing capability
  • In Xcode, under your applications Signing and Capabilities, add Keychain Sharing
  • Keychain Group should be com.microsoft.adalcache
  • Completely fine to have multiple Keychain Groups
  • This allows MSAL to use the keychain to share Microsoft Authentication sessions
  1. Set up URL Schemes
  • Add the following CFBundleURLTypes to your Info.plist file.
  • Remember to replace the bundle id.
  1. Allow MSAL to use Microsoft Authenticator if it is installed
  • Add the following LSApplicationQueriesSchemes to your Info.plist file.
  1. Handle the redirect callback
  • Import MSAL
  import MSAL
  • Within your AppDelegate.swift file add the following method
  override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    return MSALPublicClientApplication.handleMSALResponse(url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String)
  1. Ensure that the minimum target is set to iOS 11
  • In Xcode, under General > Deployment info > Set the target to be no less than iOS 11

0.0.4 #

  • Fixed dismiss error message on Android

0.0.3 #

  • Added error response messages to iOS

0.0.2 #

  • Android release

0.0.1 #

  • Initial release.


flutter_microsoft_authentication_example #

Demonstrates how to use the flutter_microsoft_authentication plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_microsoft_authentication: ^0.0.4

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_microsoft_authentication/flutter_microsoft_authentication.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-1 points)

7 out of 7 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies