Esempio n. 1
0
        /// <summary>
        /// Calls Cognito endpoint for all clients - magic experiment
        /// (for boosting the performance of all further token requests)
        /// </summary>
        /// <returns>The Task object.</returns>
        private async Task CallCognitoEndpointForAllClientsAsync()
        {
            const int numberOfCalls = 1;
            var       getTokenTasks = new List <Task <string> >();

            foreach (var client in _configSettings.Clients)
            {
                if (client.Cognito != null)
                {
                    client.Cognito.ClientApp.ClientSecret = _awsCognitoClientSecretHelper.GetClientSecretForCognitoClient(client);
                    if (string.IsNullOrEmpty(client.Cognito.ClientApp.ClientSecret))
                    {
                        continue;
                    }

                    for (int callNum = 0; callNum < numberOfCalls; callNum++)
                    {
                        getTokenTasks.Add(_awsCognitoHelper.GetClientCredentialsTokenAsync(client));
                    }
                }
            }

            await Task.WhenAll(getTokenTasks).ConfigureAwait(false);
        }