private TokenValidationParameters GetValidationParameters() { return(new TokenValidationParameters { ValidateIssuer = false, ValidateAudience = false, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_secretProvider.GetSecret())) }); }
public async Task <string> Translate(string phrase) { _logger.LogInformation($"Translating phrase: {phrase}"); var apiKey = _secretProvider.GetSecret("GoogleTranslateApiKey/bce3d012310e4196a430a8d731990f9c"); using (var service = new TranslateService(new BaseClientService.Initializer { ApiKey = apiKey, ApplicationName = ApplicationName })) { try { var response = await service.Translations.List(new[] { phrase }, "en").ExecuteAsync(); if (response.Translations.Count > 0) { return(CleanTranslation(response.Translations[0].TranslatedText)); } } catch (Exception ex) { _logger.LogError(ex, $"Error occurred while attempting to call the transation service. Unable to translate phrase: {phrase}"); } return(string.Empty); } }
public async Task OnGetAsync( Guid id) { ApiKey = _secret.GetSecret("google_maps_secret"); var slipways = await _dataStore.Slipways.GetValuesAsync(); Slipway = slipways.FirstOrDefault(_ => _.Id == id); }
public async Task OnGetAsync( Guid id) { ApiKey = _secret.GetSecret("google_maps_secret"); var ports = await _dataStore.Ports.GetValuesAsync(); var port = ports.First(_ => _.Id == id); Port = port; }
public CacheEnabledRequester(ISecretProvider secretProvider, ILogger <CacheEnabledRequester> logger) { _logger = logger; _innerRequestor = new HttpRequester(); var config = new RedisConfiguration() { AbortOnConnectFail = false, Hosts = new RedisHost[] { new RedisHost() { Host = "russian-word-page-outputcache.redis.cache.windows.net", Port = 6379 } }, Ssl = false, Password = secretProvider.GetSecret("CachePassword/8754aa61fc9444ee957e398aa0041d8e"), ConnectTimeout = 15000, }; config.ConfigurationOptions.ResponseTimeout = 10000; config.ConfigurationOptions.SyncTimeout = 10000; _cacheClient = new StackExchangeRedisCacheClient(new NewtonsoftSerializer(), config); }
public string GetSecret(string key) { return(_provider.GetSecret(key)); }