dart_azure_ad_sign_in 1.0.2 copy "dart_azure_ad_sign_in: ^1.0.2" to clipboard
dart_azure_ad_sign_in: ^1.0.2 copied to clipboard

dart_azure_ad_sign_in allows Flutter and Dart apps to obtain authentication tokens for authorized access to protected resources like Azure web APIs.

example/dart_azure_ad_sign_in_example.dart

// Copyright 2023 Patrick Hettich. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:dart_azure_ad_sign_in/dart_azure_ad_sign_in.dart';

void main(List<String> args) async {
  // Create instance of Azure SignIn, all parameters are optional.
  final azureSignIn = AzureSignIn();

  // Print the SignIn URL.
  print(azureSignIn.signInUri);

  // Opens the HTTP-Server and waits for the user to sign-in.
  // can also be cancelled with azureSignIn.cancelSignIn();
  Token token = await azureSignIn.signIn();

  // Print the token information
  printToken(token: token, title: 'Initial Token');

  // refresh an expired token
  token = await azureSignIn.refreshToken(token: token);

  // Print the updated token information
  printToken(token: token, title: 'Refreshed Token');
}

void printToken({required Token token, required String title}) {
  print(
      '------------------------------------------------------------------------------------------------------------------------------------');
  print(title);
  print(
      '------------------------------------------------------------------------------------------------------------------------------------');
  print('Status: ${token.status}');
  print('Error: ${token.error}');
  print('Error Message: ${token.errorDescription}');
  print('Refresh Token:');
  print(token.accessToken);
  print('Refresh Token:');
  print(token.accessToken);
}
4
likes
150
pub points
73%
popularity

Publisher

unverified uploader

dart_azure_ad_sign_in allows Flutter and Dart apps to obtain authentication tokens for authorized access to protected resources like Azure web APIs.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

More

Packages that depend on dart_azure_ad_sign_in