Power BI 用户（用户拥有数据）的访问令牌

从 Azure AD 获取授权代码

获取访问令牌的第一步是从 Azure AD 获取授权代码。 若要执行此操作，请构造具有以下属性的查询字符串，并重定向到 Azure AD。

授权代码查询字符串

var @params = new NameValueCollection
{
//Azure AD will return an authorization code.
//See the Redirect class to see how "code" is used to AcquireTokenByAuthorizationCode
{"response_type", "code"},
//Client ID is used by the application to identify themselves to the users that they are requesting permissions from.
//You get the client id when you register your Azure app.
{"client_id", Properties.Settings.Default.ClientID},
//Resource uri to the Power BI resource to be authorized
// https://analysis.windows.net/powerbi/api
{"resource", Properties.Settings.Default.PowerBiAPI},
//After user authenticates, Azure AD will redirect back to the web app
{"redirect_uri", "http://localhost:13526/Redirect"}
};