【发布时间】:2020-03-23 15:24:23
【问题描述】:
并且我能够获得访问令牌。接下来,我将此访问令牌保存在我的数据库中以备将来使用。使用存储在数据库中的这个令牌,我想获取用户的个人资料,但不知道该怎么做。
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' 之类的任何方法。
感谢任何帮助。
【问题讨论】:
标签: c# asp.net azure azure-active-directory powerbi