aad_oauth 0.1.7

  • Readme
  • Changelog
  • Example
  • 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();

Installation #

Add the following to your pubspec.yaml dependencies:

dependencies:
  aad_oauth: "^0.1.7"

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.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

example/README.md

aad-oauth-example #

A Flutter OAuth package example for performing user authentication against Azure Active Directory OAuth2 v2.0 endpoint.

Usage #

Register an App in the Azure App registration portal. Use native app as plattform type (with callback URL: https://login.live.com/oauth20_desktop.srf).

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

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

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

Use this package as a library

1. Depend on it

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


dependencies:
  aad_oauth: ^0.1.7

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 Nov 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

97 out of 97 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/helper/auth_storage.dart.

Run flutter format to format lib/helper/auth_storage.dart.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/model/token.dart (Run flutter format to format lib/model/token.dart.)
  • 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_request.dart (Run flutter format to format lib/request/token_request.dart.)
  • lib/request_token.dart (Run flutter format to format lib/request_token.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
flutter_secure_storage ^3.2.0 3.3.1+1
flutter_webview_plugin ^0.3.0+2 0.3.8
http ^0.12.0 0.12.0+2
shared_preferences ^0.5.2 0.5.4+3
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.11 1.14.12
http_parser 3.1.3
meta 1.1.7 1.1.8
path 1.6.4
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test