Using Azure. My registered app is a Public Client (It's a desktop Appplication).
The code below works just fine under "USERA"'s account.
However, running the same code as "USERB" I get the following exception
MSAL.NetCore.4.42.0.0.MsalClientException: ErrorCode: loopback_response_uri_mismatch Microsoft.Identity.Client.MsalClientException: Redirect Uri mismatch. Expected (/favicon.ico) Actual (/). at Microsoft.Identity.Client.Platforms.Shared.Desktop.OsBrowser.DefaultOsBrowserWebUi.AcquireAuthorizationAsync(Uri authorizationUri, Uri redirectUri, RequestContext requestContext, CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.FetchAuthCodeAndPkceInternalAsync(IWebUI webUi, CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.FetchAuthCodeAndPkceVerifierAsync(CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.GetTokenResponseAsync(CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.ExecuteAsync(CancellationToken cancellationToken) at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
pubApp = PublicClientApplicationBuilder.Create(config.ClientId)
.WithLogging(Log, LogLevel.Verbose, true)
.WithAuthority(config.Authority)
.WithRedirectUri("http://localhost:12345/")
.Build();
/**
* A call to Graph API calls the following
*/
authResult = await clientApp.AcquireTokenInteractive(scopes)
.WithUseEmbeddedWebView(false)
.WithPrompt(Prompt.SelectAccount)
.ExecuteAsync();
Please check the redirect URI that you are giving in the code.
If your app pops up a window with no address bar, then it is using the " embedded browser "
For desktop applications using embedded browser, Microsoft recommend using redirect URI as: https://login.microsoftonline.com/common/oauth2/nativeclient
If your app brings your system's default browser (such as Edge, Chrome, Firefox, etc.) to visit Microsoft login portal, then it is using the " system browser ".
For desktop applications using system browser, Microsoft recommend using redirect URI as: http://localhost
In the code, you have mentioned .WithUseEmbeddedWebView
( false ) which means you are not using embedded browser.
Please check if both user accounts are using different system browsers.
Try changing redirect URI in .WithRedirectUri() field to something like below as a workaround :
"http://localhost:12345"
or "http://localhost"
or "https://localhost"
Please find below references if they are helpful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.