2017-09-13 218 views
0

我试图验证我的应用程序使用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用户名已在此应用中获得拥有者访问权限。

回答