【发布时间】:2016-08-26 01:15:49
【问题描述】:
看起来如果我使用“https://management.core.windows.net”作为资源 ID 创建一个令牌,那么我将无法对图形 API 使用相同的 accessToken。有没有办法避免多次调用 AcquireTokenAsync?
AuthenticationResult result = authContext.AcquireTokenAsync("https://management.core.windows.net", "<some_client_id>, new Uri("https://localhost"), new PlatformParameters(PromptBehavior.Always)).Result;
TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();
tcs.SetResult(result.AccessToken);
ActiveDirectoryClient graphClient = new ActiveDirectoryClient(new Uri("https://graph.windows.net/" + result.TenantId),
() => { return tcs.Task; });
foreach (var app in graphClient.Applications.ExecuteAsync().Result.CurrentPage)
{
Console.WriteLine($"{app.AppId}, {app.DisplayName}");
}
【问题讨论】:
标签: oauth-2.0 azure-active-directory