Skip to content

AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance #2419

Description

@brijshah2709

Microsoft.Identity.Web Library

Microsoft.Identity.Web.TokenAcquisition

Microsoft.Identity.Web version

2.13.2

Web app

Sign-in users

Web API

Protected web APIs call downstream web APIs

Token cache serialization

Not Applicable

Description

We have a full stack application where front end calls our backend using app resource with user context and backend exchanges token for downstream api calls via TokenAcquisition.GetAuthenticationResultForUserAsync. While doing so we get this error:

"AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance.\r\nTrace ID: 64908389-2527-4188-8ba4-29b9e76e3c00\r\nCorrelation ID: a400dd29-ad31-4de1-933e-3e3995a7c6cc\r\nTimestamp: 2023-08-03 18:11:29Z","Data":{},"InnerException":null,"HelpLink":null,"Source":"Microsoft.Identity.Client","HResult":-2146233088,"StackTrace":"
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.HandleTokenRefreshErrorAsync(MsalServiceException e, MsalAccessTokenCacheItem cachedAccessTokenItem)\r\n

Trying to understand how backend can request token for such resources without having customer to disabled CA policy.

Reproduction steps

  1. Create conditional access policy.
  2. Request token using TokenAcquisition.GetAuthenticationResultForUserAsync
  3. See error on authResult.

Error message

"AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance.\r\nTrace ID: 64908389-2527-4188-8ba4-29b9e76e3c00\r\nCorrelation ID: a400dd29-ad31-4de1-933e-3e3995a7c6cc\r\nTimestamp: 2023-08-03 18:11:29Z","Data":{},"InnerException":null,"HelpLink":null,"Source":"Microsoft.Identity.Client","HResult":-2146233088,"StackTrace":"
at Microsoft.Identity.Client.Internal.Requests.RequestBase.HandleTokenRefreshErrorAsync(MsalServiceException e, MsalAccessTokenCacheItem cachedAccessTokenItem)\r\n

Id Web logs

n/a

Relevant code snippets

var authResult = await TokenAcquistionRetryPolicy().ExecuteAsync(() =>
{
    return TokenAcquisition.GetAuthenticationResultForUserAsync(scopes,
                    TokenAcquisitionParams.AuthenticationScheme,
                    tenantId,
                    TokenAcquisitionParams.UserFlow,
                    null);
}).ConfigureAwait(false);

Regression

n/a

Expected behavior

Should return access token.

Metadata

Metadata

Assignees

No one assigned

    Labels

    answeredquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions