Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
登录Azure AD后获取Power BI访问令牌_Azure_Api_Rest_Powerbi - Fatal编程技术网

登录Azure AD后获取Power BI访问令牌

登录Azure AD后获取Power BI访问令牌,azure,api,rest,powerbi,Azure,Api,Rest,Powerbi,我有将我登录到Azure AD的代码,但我不知道如何获取访问令牌以调用REST API或PowerBI有获取Power BI REST API访问令牌的示例代码 //The client id that Azure AD created when you registered your client app. string clientID = "{Client_ID}"; //RedirectUri you used when you register your app.

我有将我登录到Azure AD的代码,但我不知道如何获取访问令牌以调用REST API或PowerBI

有获取Power BI REST API访问令牌的示例代码

//The client id that Azure AD created when you registered your client app.
string clientID = "{Client_ID}";

//RedirectUri you used when you register your app.
//For a client app, a redirect uri gives Azure AD more details on the application that it will authenticate.
// You can use this redirect uri for your client app
string redirectUri = "https://login.live.com/oauth20_desktop.srf";

//Resource Uri for Power BI API
string resourceUri = "https://analysis.windows.net/powerbi/api";

//OAuth2 authority Uri
string authorityUri = "https://login.microsoftonline.com/common/";

// AcquireToken will acquire an Azure access token
// Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint
AuthenticationContext authContext = new AuthenticationContext(authorityUri);
var token = authContext.AcquireTokenAsync(resourceUri, clientID, new Uri(redirectUri)).Result.AccessToken;

Console.WriteLine(token);

有关详细信息,请参阅。

您没有显示代码,也没有说明使用了什么语言或库。通过调用某些函数获取访问令牌。