我正在嘗試在 AAD 中創建一個多租戶應用程式,任何組織都可以登錄。我可以使用我的憑據獲取授權令牌,當然它是我們的組織,所以它可以作業。我想要實作的是使用用戶名和密碼獲取令牌,例如:
u: [email protected] p: test1
u: [email protected] p: test2 u: [email protected] p: test3 等等...
我收到以下錯誤:AADSTS65001:用戶或管理員未同意使用 ID 為 [APP ID] 的應用程式為此用戶和資源發送互動式授權請求。
我已經從 API 權限執行了授予管理員許可,但仍然出現錯誤。我錯過了什么設定?
這是我初始化 IPublicClientAppliction 的方式:
var app = PublicClientApplicationBuilder
.Create(clientId)
.WithAuthority(AadAuthorityAudience.AzureAdMultipleOrgs)
.WithDefaultRedirectUri()
.Build();
var scopes = new string[]
{
"offline_access",
"email",
"https://outlook.office.com/IMAP.AccessAsUser.All"
};
var authToken = app.AcquireTokenByUsernamePassword(scopes,email,
password).ExecuteAsync();
親切的問候。
uj5u.com熱心網友回復:
我試圖在我的環境中重現相同的結果,結果如下:
我創建了一個Azure AD 多租戶應用程式,如下所示:

我嘗試通過使用以下引數使用同一租戶用戶的憑據,通過Postman 中的 ROPC 流生成訪問令牌:
POST https://login.microsoftonline.com/organizations/oauth2/token
client_id : xxxxxx-xxx-xxx-xxxx-xxxxxxxx
grant_type : password
scope : scope
username : user@********.onmicrosoft.com
password : ******

請注意,ROPC 流僅支持本地帳戶(最初在創建應用程式的 AAD 租戶中創建的 Azure AD 用戶帳戶)。它不支持其他租戶用戶/來賓用戶。
當我嘗試使用其他租戶用戶的憑據生成令牌時,出現以下相同的錯誤:

參考:
使用資源所有者密碼憑據授予登錄 - Microsoft Entra
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/509996.html
標籤:C#表格天蓝色活动目录
上一篇:InfragisticsLineseries次要系列和Legends未出現
下一篇:用指標直接寫入表單的位元組陣列
