【发布时间】:2018-11-14 13:23:06
【问题描述】:
我正在尝试获取 Power BI API 的访问令牌。我们的帐户是联合帐户。
我一直在尝试这个,但它一直给我一个错误,说用户名或密码不正确。为了使用资源所有者密码凭据授予流程来获取 Azure AD 的访问令牌,我使用 HttpClient 直接调用 http 请求
HttpClient clie = new HttpClient();
string tokenEndpoint = "https://login.microsoftonline.com/{tenant}/oauth2/token";
var body = "resource=https://analysis.windows.net/powerbi/api&client_id={client_id}&grant_type=password&username={username}&password={password}";
var stringContent = new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded");
string result = clie.PostAsync(tokenEndpoint, stringContent).ContinueWith((response) =>
{
return response.Result.Content.ReadAsStringAsync().Result;
}).Result;
这适用于非联合帐户。如何为联合帐户实施相同的操作?
【问题讨论】:
标签: rest authentication azure-active-directory asp.net-core-2.0 powerbi