Skip to content

Instantly share code, notes, and snippets.

@asith-w
Created May 20, 2020 19:00
Show Gist options
  • Save asith-w/c3166b7018363d94cf7807ae880b2319 to your computer and use it in GitHub Desktop.
Save asith-w/c3166b7018363d94cf7807ae880b2319 to your computer and use it in GitHub Desktop.
github-issue
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var tenantIds = new List<string>{
"1448f51b-234d-123345-86c8-0f6a634bbbb1",
"2448f51b-234d-123345-86c8-0f6a634bbbb2",
"3448f51b-234d-123345-86c8-0f6a634bbbb3",
"4448f51b-234d-123345-86c8-0f6a634bbbb4",
"5448f51b-234d-123345-86c8-0f6a634bbbb5"
};
IConfidentialClientApplication confidentialClientApplication;
//1st requests
foreach (var tenantId in tenantIds)
{
confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(_azureADConfiguration.ClientId)
.WithTenantId(tenantId)
.WithClientSecret(_azureADConfiguration.ClientSecret)
.Build();
var clientCredentialProvider = new ClientCredentialProvider(confidentialClientApplication);
var graphServiceClient = new GraphServiceClient(clientCredentialProvider);
var users = await graphServiceClient.Users
.Request()
.GetAsync();
}
//2st requests
foreach (var tenantId in tenantIds)
{
confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(_azureADConfiguration.ClientId)
.WithTenantId(tenantId)
.WithClientSecret(_azureADConfiguration.ClientSecret)
.Build();
var clientCredentialProvider = new ClientCredentialProvider(confidentialClientApplication);
var graphServiceClient = new GraphServiceClient(clientCredentialProvider);
var users = await graphServiceClient.Users
.Request()
.GetAsync();
}
//two tokens are generated for each tenant.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment