我試圖驗證我的應用程序使用PowerBi REST API。爲此,我試圖對非電力商業智能用戶使用here的示例。這是我用於身份驗證的代碼。但它給出了以下例外。Azure AD PowerBi身份驗證問題Oauth
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException了未處理 消息:類型Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException'的未處理的異常出現在mscorlib.dll 其他信息:在https://msft.sts.microsoft.com/adfs/services/trust/13/usernamemixed聯合服務返回的錯誤:ID3242:安全令牌無法通過身份驗證或授權。
我確定我輸入了正確的應用程序和組ID。
var credential = new UserPasswordCredential(Username, Password);
// Authenticate using created credentials
var authenticationContext = new AuthenticationContext(ConfigurationManager.AppSettings["authorityUrl"]);
AuthenticationResult authenticationResult = await authenticationContext.AcquireTokenAsync(ConfigurationManager.AppSettings["resourceUrl"], ConfigurationManager.AppSettings["clientId"], credential);
if (authenticationResult == null)
{
Console.WriteLine("Authentication Failed.");
}
我想知道我在做什麼錯在這裏?我的Azure用戶名已在此應用中獲得擁有者訪問權限。