我下载了这个示例:https : //github.com/Microsoft/PowerBI-Developer-Samples/tree/master/User%20Owns%20Data/integrate-report-web-app/PBIWebApp
我能够获得访问令牌。接下来,我将此访问令牌保存在我的数据库中以备将来使用。使用存储在数据库中的这个令牌,我想获取用户的个人资料,但不知道如何去做。
public string GetAccessToken(string authorizationCode, string applicationID, string applicationSecret, string redirectUri)
{
//Redirect uri must match the redirect_uri used when requesting Authorization code.
//Note: If you use a redirect back to Default, as in this sample, you need to add a forward slash
//such as http://localhost:13526/
// Get auth token from auth code
TokenCache TC = new TokenCache();
//Values are hard-coded for sample purposes
string authority = Settings.Default.AADAuthorityUri;
AuthenticationContext AC = new AuthenticationContext(authority, TC);
ClientCredential cc = new ClientCredential(applicationID, applicationSecret);
//Set token from authentication result
return AC.AcquireTokenByAuthorizationCode(
authorizationCode,
new Uri(redirectUri), cc).AccessToken;
}
我检查了 AuthenticationContext 类的方法,但它没有像“GetMe”之类的任何方法。
任何帮助表示赞赏。
相关分类