简体   繁体   English

为什么我得到一个帐户的 URI 不匹配,而另一个帐户却没有?

[英]Why do I get URI Mismatch for one account and not another?

Using Azure. My registered app is a Public Client (It's a desktop Appplication).使用 Azure。我注册的应用程序是一个公共客户端(它是一个桌面应用程序)。

The code below works just fine under "USERA"'s account.下面的代码在“USERA”的帐户下工作得很好。

However, running the same code as "USERB" I get the following exception但是,运行与“USERB”相同的代码我得到以下异常

MSAL.NetCore.4.42.0.0.MsalClientException: ErrorCode: loopback_response_uri_mismatch Microsoft.Identity.Client.MsalClientException: Redirect Uri mismatch. MSAL.NetCore.4.42.0.0.MsalClientException:错误代码:loopback_response_uri_mismatch Microsoft.Identity.Client.MsalClientException:重定向 Uri 不匹配。 Expected (/favicon.ico) Actual (/).预期 (/favicon.ico) 实际 (/)。 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)在 Microsoft.Identity.Client.Platforms.Shared.Desktop.OsBrowser.DefaultOsBrowserWebUi.AcquireAuthorizationAsync(Uri authorizationUri,Uri redirectUri,RequestContext requestContext,CancellationToken cancellationToken)在 Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.FetchAuthCodeAndPkceVerifierAsync(CancellationToken cancellationToken) cancellationToken)在 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.请检查您在代码中提供的重定向 URI。

If your app pops up a window with no address bar, then it is using the " embedded browser "如果您的应用弹出没有地址栏的 window,那么它正在使用“嵌入式浏览器

For desktop applications using embedded browser, Microsoft recommend using redirect URI as: https://login.microsoftonline.com/common/oauth2/nativeclient对于使用嵌入式浏览器的桌面应用程序,Microsoft 建议使用重定向 URI 为: 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 ".如果您的应用程序使用系统默认浏览器(如 Edge、Chrome、Firefox 等)访问 Microsoft 登录门户,那么它正在使用“系统浏览器”。

For desktop applications using system browser, Microsoft recommend using redirect URI as: http://localhost对于使用系统浏览器的桌面应用程序,Microsoft 建议使用重定向 URI 为: http://localhost

In the code, you have mentioned .WithUseEmbeddedWebView ( false ) which means you are not using embedded browser.在代码中,您提到.WithUseEmbeddedWebView ( false ) 这意味着您没有使用嵌入式浏览器。

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 :尝试将.WithRedirectUri()字段中的重定向 URI 更改为如下所示的解决方法

"http://localhost:12345" or "http://localhost" or "https://localhost" "http://localhost:12345""http://localhost""https://localhost"

Please find below references if they are helpful.如果有帮助,请查找以下参考资料。

References: Ref1 , Ref2 , Ref3参考文献: Ref1Ref2Ref3

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数据从一个 AWS 账户的 RDS 移动到另一个账户 - How do I move data from RDS of one AWS account to another account 我收到此错误:- 错误 400: redirect_uri_mismatch 即使我在 Google Gmail API OAuth 2.0 中注册了 URI - I get this error:- Error 400: redirect_uri_mismatch even after I registered the URI in Google Gmail API OAuth 2.0 为什么我需要 AWS Codestar 的开发人员账户? - Why do i need a developer account for AWS Codestar? 是否有将 azure 逻辑应用程序从一个帐户迁移到另一个帐户的过程 - Is there a procedure for migrating azure logic app from one account to another account 将 Azure 数据工厂从一个账户迁移到另一个账户 - Migrate Azure Data Factory from one account to another account 如果我管理用户的 Google 云端硬盘帐户,为什么请求会发布到我的帐户? - Why, if I manage a user's Google Drive account, do requests post to my account? 一个 AWS 账户用于支付,另一个用于维护? - One AWS account for payment, another for maintenance? Flutter:如何获取 Apple 凭据以将 Apple 帐户链接到我的 firebase 应用程序上的帐户? - Flutter: how do I get Apple credential to link an apple account to an account on my firebase app? Firebase 从一个账户移动/复制到另一个账户 - Firebase move/copy from one account to another account 如何将变量从一个 class 传递到另一个? - How do I pass variables from one class to another?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM