[英]Azure B2C with Native Client - MsalClientException: The server has not found anything matching the requested URI
嘗試從本機應用程序運行基本的 Azure AD B2C 身份驗證。 我遵循WPF 應用程序注冊指南,並使用Git 集線器示例中提供的代碼的摘錄。
使用Microsoft.Identity.Client
SDK,當我運行await app.AcquireTokenInteractive(App.ApiScopes).ExecuteAsync();
,我得到以下異常:
Microsoft.Identity.Client.MsalClientException: '基於瀏覽器的身份驗證對話框無法完成。 原因:服務器沒有找到與請求的 URI(統一資源標識符)匹配的任何內容。
我從 NUnit.net 的測試中運行它
我做了以下嘗試和檢查:
嘗試了推薦的 URI: https://mytenanturl.com.b2clogin.com/oauth2/nativeclient
嘗試了自定義 URI,例如https://mytenanturl.com/test/auth/nativeclient
嘗試了自定義 URI,例如uri://mytenanturl.com/test/auth/nativeclient
嘗試了在 Azure 上默認預注冊的 3 個 URI 之一: https://login.microsoftonline.com/common/oauth2/nativeclient
嘗試使用本地 URI,例如https://127.0.0.1/dev/
這些 URI 都在 Azure Portal / App Registration / Authentication
上注冊, Platform Configuration
設置為Mobile and desktop applications
在 App Regsitration Manifest 中,它說
“replyUrlsWithType”:[{“url”:“https://127.0.0.1/dev”,“type”:“InstalledClient”},{“url”:“https://login.microsoftonline.com/common/oauth2 /nativeclient", "type": "InstalledClient" } 等,
當我檢查IPublicClientApplication
object 時,我可以看到正確包含在.AppConfig.RedirectUri
中的 URI。 但是, PublicClientApplication.RedirectUri
說它是 Null。 我很困惑,因為我什至無法理解該屬性的來源,因為它沒有出現在文檔中,其中PublicClientApplication Class
或其父類沒有RedirectUri
屬性。
我究竟做錯了什么?
Ms 文檔中提供的示例顯示客戶端構建器調用.WithB2CAuthority(AuthoritySignUpSignIn)
,這是不正確的。
Azure AD App Registration 頁面中的 QuickStart 刀片顯示使用WithAuthority(AzureCloudInstance.AzurePublic, Tenant)
,其中Tenant
可以是companyurl.com
或應用注冊概述頁面上提供的Directory (tenant) Id
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.