aad_oauth 0.1.9

  • Readme
  • Changelog
  • Installing
  • 92

Azure Active Directory OAuth #

A Flutter OAuth package for performing user authentication against Azure Active Directory OAuth2 v2.0 endpoint. Forked from hitherejoe.FlutterOAuth.

Supported Flows:

Usage #

For using this library you have to create an azure app at the Azure App registration portal. Use native app as platform type (with callback URL: https://login.live.com/oauth20_desktop.srf).

Afterwards you have to initialize the library as follow:

final Config config = new Config(
  "YOUR TENANT ID",
  "YOUR CLIENT ID",
  "openid profile offline_access",
  "your redirect url available in azure portal");
final AadOAuth oauth = new AadOAuth(config);

This allows you to pass in an tenant ID, client ID, scope and redirect url.

Then once you have an OAuth instance, you can call login() and afterwards getAccessToken() to retrieve an access token:

await oauth.login();
String accessToken = await oauth.getAccessToken();

You can also call getAccessToken() directly. It will automatically login and retrieve an access token.

Tokens are stored in Keychain for iOS or Keystore for Android. To destroy the tokens you can call logout():

await oauth.logout();

B2C Usage #

Setup your B2C directory - Azure AD B2C Setup.

Register an App on the previously created B2C directory - Azure AD B2C App Register.

Use native app as plattform type (with callback URL: https://login.live.com/oauth20_desktop.srf).

Create your user flows - Azure AD B2C User Flows

Add your Azure tenant ID, tenantName, client ID (ID of App), client Secret (Secret of App) and redirectUrl in the main.dart source-code:

static final Config configB2C = new Config(
    "YOUR_TENANT_ID",
    "YOUR_CLIENT_ID",
    "YOUR_CLIENT_ID offline_access",
    "https://login.live.com/oauth20_desktop.srf",
    clientSecret: "YOUR_CLIENT_SECRET",
    isB2C: true,
    azureTennantName: "YOUR_TENANT_NAME",
    userFlow: "YOUR_USER_FLOW",
    tokenIdentifier: "UNIQUE IDENTIFIER A",
  );

Afterwards you can login and get an access token for accessing other resources.

Installation #

Add the following to your pubspec.yaml dependencies:

dependencies:
  aad_oauth: "^0.1.9"

Contribution #

Contributions can be submitted as pull requests and are highly welcomed. Changes will be bundled together into a release. You can find the next release date and past releases in the CHANGELOG file.

[0.1.9] - 20200529 #

[0.1.8] - 20200203 #

  • Fix requested bug on auth cancel
  • Modified to take into account Api permission in Azure AD rather than de default one

[0.1.7] - 20190430 #

[0.1.6] - 20190419 #

  • Fix Token Refresh URL

[0.1.5] - 20190413 #

[0.1.4] - 20190325 #

  • Change from memory cache to secure storage

[0.1.3] - 20190212 #

  • Fix iOS issue by encoding the URL
  • Change dependency of example to local library

[0.1.2] - 20181229 #

  • Added example README

[0.1.1] - 20181229 #

  • Added an example

[0.1.0] - 20181229 #

  • Adjusted library interface
  • Bug fixing

[0.0.1] - 20181228 #

  • Initial release

Use this package as a library

1. Depend on it

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


dependencies:
  aad_oauth: ^0.1.9

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:aad_oauth/aad_oauth.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
85
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
92
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:aad_oauth/aad_oauth.dart, package:shared_preferences/shared_preferences.dart] that declares support for platforms: android, ios, macos, web

Package does not support Flutter platform macos

Because of import path [package:aad_oauth/aad_oauth.dart, package:aad_oauth/request_code.dart, package:flutter_webview_plugin/flutter_webview_plugin.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:aad_oauth/aad_oauth.dart, package:aad_oauth/request_code.dart, package:flutter_webview_plugin/flutter_webview_plugin.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:aad_oauth/aad_oauth.dart, package:shared_preferences/shared_preferences.dart] that declares support for platforms: android, ios, macos, web

Package not compatible with SDK dart

because of import path [aad_oauth] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

110 out of 110 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.

Fix lib/request_code.dart. (-1 points)

Analysis of lib/request_code.dart reported 2 hints:

line 2 col 8: Unused import: 'dart:ui'.

line 3 col 8: Unused import: 'package:flutter/widgets.dart'.

Format lib/aad_oauth.dart.

Run flutter format to format lib/aad_oauth.dart.

Format lib/model/config.dart.

Run flutter format to format lib/model/config.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/request/authorization_request.dart (Run flutter format to format lib/request/authorization_request.dart.)
  • lib/request/token_refresh_request.dart (Run flutter format to format lib/request/token_refresh_request.dart.)
  • lib/request_token.dart (Run flutter format to format lib/request_token.dart.)

Maintenance suggestions

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and aad_oauth.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
flutter 0.0.0
flutter_secure_storage ^3.2.0 3.3.3
flutter_webview_plugin ^0.3.0+2 0.3.11
http ^0.12.0 0.12.1
shared_preferences ^0.5.2 0.5.7+3
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
flutter_web_plugins 0.0.0
http_parser 3.1.4
meta 1.1.8
path 1.7.0
pedantic 1.9.0 1.9.1
shared_preferences_macos 0.0.1+10
shared_preferences_platform_interface 1.0.4
shared_preferences_web 0.1.2+7
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test