-
Notifications
You must be signed in to change notification settings - Fork 210
Description
Describe the bug
Calling PublicClientApplication.acquire_token_interactive() when the user does not have access to the resource shows an error in the browser, but the acquire_token_interactive() method does not return an error - it remains in the time.sleep(1) loop indefinitely (even if the browser window is closed). Ctrl+C terminates the process.
To Reproduce
- Use https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/dev/sample/interactive_sample.py
- Configure as
{
"authority": "https://login.microsoftonline.com/organizations",
"client_id": "37b12803-e95b-4e78-9a16-e01706d75b3c",
"scope": ["User.ReadBasic.All"],
"endpoint": "https://graph.microsoft.com/v1.0/users"
}
Note: The client ID is an internal proof-of-concept Azure AD application.
3. Run the sample python interactive_sample.py config.json
4. The browser opens and informs the user that they don't have access. There is no "continue" or "exit" button.

5. The script continues running indefinitely, without erroring.
Expected behaviour
acquire_token_interactive() returns a dict containing an error_description.
What you see instead
python .\interactive_sample.py .\config.json
A local browser window will be open for you to sign in. CTRL+C to cancel.
Ctrl+C terminates the process with a stack trace pointing to time.sleep(1).
The MSAL Python version you are using
1.25.0
Additional context
Windows 10. Default browser Chrome. Python 3.11. Running from VS Code terminal.
Not configured to use broker on windows.
I believe the Azure AD side of things is configured correctly with respect to redirect URLs - when I am granted permissions, the browser shows success and the acquire_token_interactive() returns with a valid access_token.
Some errors shown in the browser do result in acquire_token_interactive() with an error, e.g. requesting a non-existent scope api://37b12803-e95b-4e78-9a16-e01706d75b3c/fake-scope.
Our workaround is to set the timeout parameter, despite #516 recommending against this in interactive auth flows, and the resulting error just being an AssertionError.
Please accept my apologies if this isn't an issue with the MSAL Python library, or if we've misconfigured our Azure AD application.