0
看起來好像我是否使用「https://management.core.windows.net」作爲資源ID創建令牌,那麼我將無法對圖API使用相同的accessToken 。有沒有辦法避免多次調用AcquireTokenAsync?我可以使用相同的accessToken訪問Azure AD圖api和Azure管理資源嗎?
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}");
}