private async Task <string> TokenFactoryAsync(ICacheEntry cacheEntry)
        {
            string token = await _apiClient.GetAccessTokenAsync(_configuration.Email, _configuration.Password);

            var jwtSecurityToken = new JwtSecurityToken(token);

            cacheEntry.AbsoluteExpiration = jwtSecurityToken.ValidTo - TokenExpirationSkew;

            return(token);
        }
Exemple #2
0
        public async Task SetupAsync()
        {
            var httpClient = new HttpClient();

            _client = new SimaLandApiClient(httpClient);

            _email = Environment.GetEnvironmentVariable(EmailEnvironmentVariableName)
                     ?? throw EnvironmentVariableException(EmailEnvironmentVariableName);

            _password = Environment.GetEnvironmentVariable(PasswordEnvironmentVariableName)
                        ?? throw EnvironmentVariableException(PasswordEnvironmentVariableName);

            string token = await _client.GetAccessTokenAsync(_email, _password);

            _client.SetAccessToken(token);