IDW10502: An MsalUiRequiredException was thrown due to a challenge for the user - Clarification

See original GitHub issue

Hi, i’m sorry for this duplicate, but i still don’t understand the responses made on issue opened: 1568

This needs some clarification.

I checked the example told by @jennyf19 but i don’t understand how you can get a token from cache without the 2 required paramers (objectId and TenantId).

I have a similar implementation like it is described here, with the diference i have distributed cache with 2 levels. Memory cache and a database cache. I have the exact same problem, when i try to retrieve an object from cache it raises the same error. Quite doubtfull because i provide an user context which i prevously recorded while the user was subscribing to Graph. A little more detail: I’m saving the TenantId, ObjectId and SubscriptionId (this one for managing purposes). I do this as i said, when the user is subscribing to Graph notifications. When i receive a callback via Lifecycle endpoint, i try to obtain an access token from cache and interact later with Microsoft Graph by injecting the access token into the GraphServiceClient class. The code breaks at the last line.

…Code simplified for brevity… HttpContext.User=ClaimsPrincipalFactory.FromTenantIdAndObjectId(tenantId,objectId); string[] scope=new string[]{"access_as_user"}; AuthenticationResult result=await _tokenAcquisition.GetAuthenticationResultForUserAsync(scope,tenantId,null,User); Is there an issue with the ClaimsPrincipalFactory class? Or with the DI TokenAcquistion?

I opened a github issue regarding the documentation example on the ClaimsPrincipalFactory class. The example is poorly described. https://github.com/Azure/azure-sdk-for-net/issues/28231

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jmprieurcommented, Apr 23, 2022

Thanks for the update, @MarcoEnxuto. Glad you are unblocked.

@bgavrilMS @pmaytak @trwalke @gladjohn @SameerK-MSFT : FYI This is exactly the kind of scenarios for which we designed the long running process.

0reactions
MarcoEnxutocommented, Apr 23, 2022

Alright @jmprieur . What i did was, to provide a value to the property LongRunningWebApiSessionKey by setting to an identifier (here used as a key for the session) upon user subscription to my endpoint. The access token is cached by design. Later i get an access token from the cache, even a refreshed one, and then i call the Microsoft API on behalf of the user. This happens when i have to deal with Lifecycle Notification events A callback from the service (MSGraph). If anyone has any questions, i can explain in more detail. Thanks for your time!

Read more comments on GitHub >

github_iconTop Results From Across the Web

IDW10502: An MsalUiRequiredException was thrown due ...
Message: IDW10502: An MsalUiRequiredException was thrown due to a challenge for the user. Inner exception: No account or login hint was passed ...
Read more >
[Bug] IDW10502: An MsalUiRequiredException was thrown ...
I get this exception exception when running the Post controller. ... Message: An error occurred sending the request. ---> Microsoft.Identity.Web.
Read more >
Handle errors and exceptions in MSAL.NET
If MsalUIRequiredException is thrown, it's an indication that an interactive flow needs to happen for the user to resolve the issue.
Read more >
MsalUiRequiredException Class (Microsoft.Identity.Client)
When this property is not null or empty, this means that the service requires the user to provide additional claims, such as doing...
Read more >
comments
SOLUTION: MicrosoftIdentityWebChallengeUserException: IDW10502: An MsalUiRequiredException was thrown due to a challenge for the user.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found