Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

[Bug] MSAL.PY's error has no indicator for `InteractionRequired`

Offen
#701 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
python

Rechercherichtung

Start by reading the MSAL Python error handling and token acquisition paths referenced by the issue, along with the linked Azure CLI handling and interactive sample. Identify how errors expose interaction requirements with and without WAM. Done means MSAL provides a clear indicator clients can use without parsing error_description.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

ado investigate public-client

Describe the bug
Azure CLI relies on AADSTS50076 to detect MFA error (https://github.com/Azure/azure-cli/pull/12516):

https://github.com/Azure/azure-cli/blob/fb6630fd3081483195b00a740e9e645b0a18e2d3/src/azure-cli-core/azure/cli/core/_profile.py#L765

                if 'AADSTS50076' in msg:
                    # The tenant requires MFA and can't be accessed with home tenant's refresh token
                    mfa_tenants.append(t)

and let the user know interaction is required:

https://github.com/Azure/azure-cli/blob/fb6630fd3081483195b00a740e9e645b0a18e2d3/src/azure-cli-core/azure/cli/core/_profile.py#L797-L802

        # Show warning for MFA tenants
        if mfa_tenants:
            logger.warning("The following tenants require Multi-Factor Authentication (MFA). "
                           "Use 'az login --tenant TENANT_ID' to explicitly login to a tenant.")
            for t in mfa_tenants:
                logger.warning("%s", t.tenant_id_name)

Today I was told by MSAL team that clients shouldn't parse error_description. However, MSAL.PY has no clear indicator that interaction is required, with or without WAM:

With WAM:

{
    "error": "broker_error",
    "error_description": "SubError: basic_action V2Error: invalid_grant AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access 'xxx'. Trace ID: xxx Correlation ID: xxx Timestamp: 2024-05-15 01:13:49Z. Status: Response_Status.Status_InteractionRequired, Error code: 3399614476, Tag: 557973645",
    "msal_telemetry": "..."
}

Without WAM:

{
    "error": "invalid_grant",
    "error_description": "AADSTS50076: Due to a configuration change made by your administrator, or because you moved to a new location, you must use multi-factor authentication to access 'xxx'. Trace ID: xxx Correlation ID: xxx Timestamp: 2024-05-15 01:16:43Z",
    "error_codes": [
        50076
    ],
    "timestamp": "2024-05-15 01:16:43Z",
    "trace_id": "xxx",
    "correlation_id": "xxx",
    "error_uri": "https://login.microsoftonline.com/error?code=50076",
    "suberror": "basic_action",
    "classification": "basic_action"
}

This makes Azure CLI have no way of knowing whether the error can be recovered by performing interactive authentication.

The MSAL example unconditionally launches acquire_token_interactive if acquire_token_silent fails to get an access token:

https://github.com/AzureAD/microsoft-authentication-library-for-python/blob/2d03ad97c5ef865b8d9d1a79b61fb08d6fbdea29/sample/interactive_sample.py#L63-L66

To Reproduce
az login with an account that requires MFA for non-home tenants.

Expected behavior
MSAL.PY's error should have an indicator for InteractionRequired.

What you see instead
MSAL.PY's error has no indicator for InteractionRequired.

The MSAL Python version you are using
1.28.0

Additional context
Add any other context about the problem here.

Vorherrschende Sprache
Python
Sterne
971
Forks
223
Ø Merge
13 Std. 48 Min.
Gemergte PRs (30 T.)
2

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus AzureAD/microsoft-authentication-library-for-python

Alle Issues in AzureAD/microsoft-authentication-library-for-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.