#pragma warning disable UseAsyncSuffix // Use Async suffix public async Task <long> Get() #pragma warning restore UseAsyncSuffix // Use Async suffix { var tid = $"tid{s_random.Next(Settings.NumberOfTenants)}"; bool cacheHit = s_random.NextDouble() <= Settings.CacheHitRatio; ParallelRequestMockHandler httpManager = new ParallelRequestMockHandler(); var cca = ConfidentialClientApplicationBuilder .Create("d3adb33f-c0de-ed0c-c0de-deadb33fc0d3") .WithAuthority($"https://login.microsoftonline.com/{tid}") .WithHttpManager(httpManager) .WithClientSecret("secret") .BuildConcrete(); s_flatTokenCache.Bind(cca.AppTokenCache as TokenCache); var res = await cca.AcquireTokenForClient(new[] { "scope" }) .WithForceRefresh(!cacheHit) .ExecuteAsync().ConfigureAwait(false); return(res.AuthenticationResultMetadata.DurationTotalInMs); }
private static ConfidentialClientApplication CreateCCA() { ParallelRequestMockHandler httpManager = new ParallelRequestMockHandler(); return(ConfidentialClientApplicationBuilder .Create("d3adb33f-c0de-ed0c-c0de-deadb33fc0d3") .WithHttpManager(httpManager) .WithClientSecret("secret") .BuildConcrete()); }