nayanAubie / msal_auth

A new Flutter plugin for Azure AD authentication.
MIT License
8 stars 10 forks source link

Flutter Android - Getting Invalid authority URL #27

Open gtl-himanshu opened 1 month ago

gtl-himanshu commented 1 month ago

Hello,

Thank you for the Flutter library.

iOS: Everything is working perfectly.
Android: Everything is working fine except for getting error while retrieving token silently.

Error: MSAL exception with error: Invalid authority URL.

Scenario: After logging in via an organizational account and being redirected back to the main screen, when I click on the Get Token Silent button, I receive the Invalid authority URL error in the logs.

msal_config.json

{
  "redirect_uri": "msauth://com.example.msal_auth_example/XXXXXxxxxwxxXXXXXXX", //signature hash
  "authorities" : [
    {
      "type": "AAD",
      "authority_url": "https://login.microsoftonline.com/xx-XXXX-XXXX-XXXX-xxx", // tenantId
      "audience": {
        "type": "AzureADandPersonalMicrosoftAccount",
        "tenant_id": "xxxx-XXXX-XXXX-XXXX-XXX"
      },
      "default": true
    }
  ],
  "multiple_clouds_supported": false,
  "broker_redirect_uri_registered": false,
  "authorization_user_agent": "WEBVIEW",
  "http": {
    "connect_timeout": 10000,
    "read_timeout": 30000
  },
  "logging": {
    "pii_enabled": false,
    "log_level": "WARNING",
    "logcat_enabled": false
  },
  "shared_device_mode_supported": false,
  "account_mode": "MULTIPLE"
}

AndroidManifest.xml

<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="com.example.msal_auth_example"
                    android:path="/xxxxxxxxxxxxx+xxxxxxxxxY="
                    android:scheme="msauth" />
            </intent-filter>
        </activity>

Using flutter web-view for MS login.

Please review above code and let me know what changes are required.

I am getting stuck in this issue from last 2 days, tried so many ways but no success.

Please help.

nayanAubie commented 1 month ago

@gtl-himanshu Are you using B2C?