azure_ad_oauth 0.4.1 copy "azure_ad_oauth: ^0.4.1" to clipboard
azure_ad_oauth: ^0.4.1 copied to clipboard

unlisted

Flutter Azure AD oAuth - based on webview_flutter 4.x.x package.

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, _) {
            ...
copied to clipboard
  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
copied to clipboard
  1. For local testing - add following config to your launch.json:
        {
            "name": "Web Chrome",
            "request": "launch",
            "type": "dart",
            "args": ["-d", "chrome","--web-port", "45678"],
        },
copied to clipboard
  1. Add authRedirect.html file to your web folder with the following content:
<script>
    window.opener.postMessage(window.location.href, '*');
</script>
copied to clipboard

You are done!

0
likes
130
points
484
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.21 - 2025.04.05

Flutter Azure AD oAuth - based on webview_flutter 4.x.x package.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, flutter_secure_storage, http, pedantic, shared_preferences, webview_flutter

More

Packages that depend on azure_ad_oauth