Is your feature request related to a problem? Please describe.
When a mgmt-plane request gets blocked by MFA policy, only the claims challenge from WWW-Authenticate header is passed to get_token_info via options['claims'].
The response body of the 401 response is discarded as Body is streamable:
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/9fb3fda4-e572-422a-a972-1011d3593176/resourceGroups/testpolicy1/providers/Microsoft.KeyVault/vaults/kv06171?api-version=2023-02-01'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
...
cli.azure.cli.core.sdk.policies: Response status: 401
cli.azure.cli.core.sdk.policies: Response headers:
...
cli.azure.cli.core.sdk.policies: 'WWW-Authenticate': 'Bearer realm="", authorization_uri="https://login.microsoftonline.com/common/oauth2/authorize", error="insufficient_claims", claims="eyJhY2Nlc3NfdG9rZW4iOnsiYWNycyI6eyJlc3NlbnRpYWwiOnRydWUsInZhbHVlcyI6WyJwMSJdfX19"'
...
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: Body is streamable
However, the response body contains detailed information on the policy that rejected the request. The response body should be displayed to the user.
Describe the solution you'd like
SDK should have a way to pass the 401 response body to the credential that implements get_token_info so that it can display the response body accordingly.
For example, get_token_info's options can have a new field called body that contains the 401 response body.
Describe alternatives you've considered
N/A
Additional context
Is your feature request related to a problem? Please describe.
When a mgmt-plane request gets blocked by MFA policy, only the claims challenge from
WWW-Authenticateheader is passed toget_token_infoviaoptions['claims'].The response body of the
401response is discarded asBody is streamable:However, the response body contains detailed information on the policy that rejected the request. The response body should be displayed to the user.
Describe the solution you'd like
SDK should have a way to pass the
401response body to the credential that implementsget_token_infoso that it can display the response body accordingly.For example,
get_token_info'soptionscan have a new field calledbodythat contains the401response body.Describe alternatives you've considered
N/A
Additional context
--claims-challengeto the re-authentication message azure-cli#31699 (comment)on_challengeimplementation in auth policies #31215get_token_infotoken protocol in {Auth} Supportget_token_infoprotocol azure-cli#30928