flutter_aad 0.3.14

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

flutter_aad #

Pub Build Status codecov

A Dart package for interacting with the Azure Active Directiory platform (v1 and v2).

Warning: this project is very much still in development

Azure Active Directory Docs #

Docs for this lib are available here.

[0.3.14] - 20190122

  • add cb to constructor

[0.3.13] - 20190122

  • remove unneeded logging

[0.3.12] - 20190122

  • better error handling and some logging

[0.3.11] - 20190122

  • added check for 403 as well as 401 for refresh on FBA

[0.3.10] - 20190115

  • can now set host in constructor as well

[0.3.9] - 20190110

  • testing a fba refresh call back

[0.3.8] - 20181229

  • can now clone configs

[0.3.7] - 20181228

  • fixed bug onlyOutput path

[0.3.6] - 20181228

  • added ability to only output and not update internal token
  • added ability to make a token_header with given token

[0.3.5] - 20181228

  • adding refresh overrides for adding access to tokens

[0.3.4] - 20181106

  • moved to http 0.12.0

[0.3.3] - 20181101

  • helps if logggedIn works with fedAuth as well

[0.3.2] - 20181101

  • now keeping track of the host for you!

[0.3.1] - 20181101

  • host for FBAlogin should include protocol now
  • (still testing if this is stable)

[0.3.0] - 20181031

  • lots of spooky changes! (Suggest not touching this version until I have it evened out... sorry)
  • major changes to how auth is handled so that we can also (hopefully) handle "on site" Form Based Authentications

[0.2.9] - 20181022

  • fixed some params for search

[0.2.8] - 20181009

  • move back to 0.11.0 for http since that's what beta channel is on
  • added token getter that also returns the response so that you can get at the headers as well if needed

[0.2.7] - 20181004

  • use latest http

[0.2.6] - 20180921

  • made refresh more selective

[0.2.5] - 20180921

  • added expand to list item calls

[0.2.4] - 20180920

  • improved sharepoint search call

[0.2.3] - 20180920

  • added sharepoint search call

[0.2.2] - 20180917

  • added stream for watching login state

[0.2.1] - 20180917

  • now have 100% coverage
  • fixed a couple of bugs found by improving the testing

[0.2.0] - 20180915

  • config is now stored on FlutterAAD instance so we don't have pass it into every function, but you can always make another instance with a different config if you need to!
  • with the move of the config into state it made sense to also store the token in state and update calls accordingly

[0.1.4] - 20180915

  • Improving descriptions

[0.1.3] - 20180915

  • fixed example to match new code pattern

[0.1.2] - 20180915

  • small bug really fixed

[0.1.1] - 20180915

  • small bug fix

[0.1.0] - 20180914

  • broke a LOT of function signatures... was needed for the auth-refresh
  • added apiVersion to AADConfig to keep the interface consistant
  • merged all v1 and v2 calls to take advantage of the new apiVersion in the config
  • now default to trying to refresh our token if need up to config.refreshTries times
  • moved non-token-refreshing versions out and renamed them as auto-refreshing should now be the default

[0.0.10] - 20180913

  • added example
  • working on docs
  • forgot the v2 variation of GetTokenMapWithAuthCode
  • added onError callbacks for all the calls that didn't have them before and needed them

[0.0.9] - 20180913

  • Added Get My Profile methods

[0.0.8] - 20180912

  • Added token refresh call and updates

[0.0.7] - 20180912

  • added get for full token to use when you need more than the access_token

[0.0.6] - 20180911

  • bit of refactoring

[0.0.5] - 20180911

  • little clean up and can now get list items either parsed for you or just the response (so you can send it into built_value directly if you like)

[0.0.4] - 20180910

  • added get list items api call

[0.0.3] - 20180910

  • testing should be good and getting tokens should be good

[0.0.2] - 20180910

  • Now has mocking for http tests
  • Started filling out the token system a bit more

[0.0.1] - 20180910

  • Getting the base in for what I'm doing now

example/main.dart

import 'dart:convert';
import 'dart:io';

import 'package:flutter_aad/flutter_aad.dart';

void main() async {
  Map<String, String> envVars = Platform.environment;
  final aadConfig = AADConfig(
      resource: envVars['AAD_RESOURCE'],
      clientID: envVars['AAD_CLIENT_ID'],
      redirectURI: envVars['AAD_REDIRECT_URI'],
      scope: [
        "openid",
        "offline_access",
        "Sites.Read.All",
        "User.Read",
        "profile"
      ]);

  var aad = FlutterAAD(aadConfig);

  final auth_code_uri = await aad.GetAuthCodeURI();
  print(
      "Please use a browsers to access the following url and then copy and paste the uri it redirected you to here:" +
          auth_code_uri);
  final redirected_uri = Uri.parse(stdin.readLineSync());

  if (!redirected_uri.hasQuery ||
      redirected_uri.queryParameters["code"] == null) {
    print("ERROR GETTING AUTH CODE!!!");
    print(redirected_uri);
    return;
  }

  final authCode = redirected_uri.queryParameters["code"];

  var full_token = await aad.GetTokenMapWithAuthCode(authCode);

  if (full_token == null) {
    print("ERROR GETTING TOKEN!!!");
    return;
  }

  print("Full token:");
  print(full_token);

  JsonEncoder encoder = new JsonEncoder.withIndent('  ');

  var profile = await aad.GetMyProfile();
  print("here is the profile:");
  print(encoder.convert(profile));

  var lists = await aad.GetListItems(aadConfig.resource, "Documents");
  print("Here is our lists:");
  print(encoder.convert(lists.map));
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_aad: ^0.3.14

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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_aad/flutter_aad.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
37
Health:
Code health derived from static analysis. [more]
87
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Health suggestions

Fix lib/src/aad_calls.dart. (-12.22 points)

Analysis of lib/src/aad_calls.dart reported 26 hints, including:

line 41 col 14: Unnecessary new keyword.

line 49 col 14: Unnecessary new keyword.

line 102 col 29: Unnecessary new keyword.

line 183 col 33: Use isNotEmpty instead of length

line 367 col 9: Use isEmpty instead of length

Fix lib/src/aad_classes.dart. (-1 points)

Analysis of lib/src/aad_classes.dart reported 2 hints:

line 36 col 51: Don't explicitly initialize variables to null.

line 44 col 38: Don't explicitly initialize variables to null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
corsac_jwt ^0.1.2 0.1.2
http ^0.12.0 0.12.0+2
meta ^1.1.6 1.1.8
Transitive dependencies
asn1lib 0.5.14
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.4
http_parser 3.1.3
logging 0.11.3+2
path 1.6.4
pedantic 1.9.0
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test ^1.3.0
test_coverage ^0.2.0