Hi,
I'm trying to implement the ability to read Outlook emails in my application (https://learn.microsoft.com/en-us/training/modules/msgraph-dotnet-core-show-user-emails/1-introduction), but I'm facing a problem because Graph needs to launch the services services // Add support for OpenId authentication .AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) failed
because an OpendConnectId Schema already exists
I think This code causes issue in Startup.cs
services // 2. Add support for OpenId authentication
.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(Configuration)
How to fix this problem THANKS
32 Answer(s)
-
0
ok, thks but after changing in Startup
app.UseEndpoints(endpoints => { // For Dashboard Elsa endpoints.MapRazorPages();
the message is still the same : Status Code: 0 Microsoft.Graph.ServiceException: Code: generalException Message: An error occurred sending the request.---> System.InvalidOperationException: IDW10503: Cannot determine the cloud Instance. The provided authentication scheme was ''. Microsoft.Identity.Web inferred 'Identity.Application' as the authentication scheme. Available authentication schemes are 'Identity.Application,Identity.External,Identity.TwoFactorRememberMe,Identity.TwoFactorUserId,OpenIdConnect,AzureAd'. See https://aka.ms/id-web/authSchemes. at Microsoft.Identity.Web.TokenAcquisitionAspnetCoreHost.GetOptions(String authenticationScheme, String& effectiveAuthenticationScheme)
-
0
Hi @Bernard,
I reproduced the error. I will try to fix this. Thanks for your feedback
-
0
Thks very much !
-
0
Hi @Bernard,
Could you update
GraphEmailClient
to following code// Get initial page of messages pagedMessages = await _graphServiceClient.Me.Messages .Request() .WithAuthenticationScheme("AzureAd") .Select(msg => new { msg.Subject, msg.BodyPreview, msg.ReceivedDateTime }) .Top(top) .OrderBy("receivedDateTime desc") .GetAsync();
-
0
Hi,
The error message in logs has changed :
IDW10502: An MsalUiRequiredException was thrown due to a challenge for the user. See https://aka.ms/ms-id-web/ca_incremental-consent.
-
0
Hi
I changed several things, but you solution for schemas is right.
Now next steps for me is to solve this issue :
Microsoft.Graph.ServiceException: Code: generalException Message: An error occurred sending the request.
---> Microsoft.Identity.Web.MicrosoftIdentityWebChallengeUserException: IDW10502: An MsalUiRequiredException was thrown due to a challenge for the user. See https://aka.ms/ms-id-web/ca_incremental-consent. ---> MSAL.NetCore.4.61.3.0.MsalUiRequiredException: ErrorCode: user_null Microsoft.Identity.Client.MsalUiRequiredException: No account or login hint was passed to the AcquireTokenSilent call.
I trying diffetent Stackoverflow solution but no chances at the moment.
Maybe a token refresh issue ? Any idea ?
Thks for all.
-
0
Hi @Bernard,
Could you check https://stackoverflow.com/questions/73886403/idw10502-an-msaluirequiredexception-was-thrown-due-to-a-challenge-for-the-user