azure_ad_oauth 0.0.1-fwp copy "azure_ad_oauth: ^0.0.1-fwp" to clipboard
azure_ad_oauth: ^0.0.1-fwp copied to clipboard

unlisted

Flutter Azure AD oAuth client for web, iOS nad Android.

Azure AD oAuth client. #

Fully automated oAuth client for Azure Active Directory. All you need to call is login(), logout(), and await OAuth.instance.token to get your token. Everything else is taken care of by the plugin behind the scenes.

How to use this plugin #

  1. Copy authenticator.dart file from the example's lib folder and provide your tenantId and clientId values, update other settings as necessary. This class is using singleton pattern with ChangeNotifier, so you can use it anywhere in your app.

  2. Provide context to the config berfore calling login() method something like so:

  @override
  Widget build(BuildContext context) {
    return AnimatedBuilder(
        animation: OAuth.instance..config.context = context,
        builder: (context, _) {
            ...
  1. Now you can call login() and logout() methods. To make authenticated calls - add Authorizetion: Bearer ${await OAuth.instance.token} to your request headers.

Web setup: #

Please note: web auth done in popup only. Due to some browser security restrictions, embedding auth screen in iframe tag is not possible.

  1. For local testing - register Web App in AAD and whitelist the following URL:
http://localhost:45678/authRedirect.html
  1. For local testing - add following config to your launch.json:
        {
            "name": "Web Chrome",
            "request": "launch",
            "type": "dart",
            "args": ["-d", "chrome","--web-port", "45678"],
        },
  1. Add authRedirect.html file to your web folder with the following content:
<script>
    window.opener.postMessage(window.location.href, '*');
</script>

You are done!

0
likes
0
pub points
51%
popularity

Publisher

unverified uploader

Flutter Azure AD oAuth client for web, iOS nad Android.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

flutter, flutter_secure_storage, flutter_webview_plugin, http, shared_preferences

More

Packages that depend on azure_ad_oauth