Exemplo n.º 1
0
 public void CreateOrRotateClient(ServiceApiKey apiKey)
 {
     ApiKey = apiKey;
     Client = new YouTubeService(new BaseClientService.Initializer {
         ApplicationName = GetType().ToString(),
         ApiKey          = apiKey.Key
     });
 }
        public async Task <ServiceApiKey> GetApiKey(string type, string userId)
        {
            var result = new ServiceApiKey {
                Id          = System.Guid.NewGuid(),
                Description = "Test API Key",
                Key         = Environment.GetEnvironmentVariable("PODNOMS_API_TESTING_YTKEY"),
                Tainted     = false
            };

            return(await Task.FromResult(result));
        }
        public async Task <ServicesApiKeyLog> LogRequest(ServiceApiKey apiKey, string requesterId, string stackTrace)
        {
            try {
                var log = apiKey.LogRequest(requesterId, stackTrace);
                await _unitOfWork.CompleteAsync();

                return(log);
            } catch (Exception e) when(e is NullReferenceException or DbUpdateException)
            {
                _logger.LogError("Error saving external service request");
                _logger.LogError(e.Message);
                return(null);
            }
        }
    }
Exemplo n.º 4
0
 public async Task <ServicesApiKeyLog> LogRequest(ServiceApiKey apiKey, string requesterId, string stackTrace)
 {
     return(await Task.FromResult(new ServicesApiKeyLog {
         Id = Guid.NewGuid(),
         Stack = Guid.NewGuid().ToString(),
         ApiKey = new ServiceApiKey {
             Id = Guid.NewGuid(),
             Description = "TestKey",
             Key = Guid.NewGuid().ToString(),
             Tainted = false
         },
         RequesterId = Guid.NewGuid().ToString(),
         CreateDate = DateTime.Today,
         UpdateDate = DateTime.Today
     }));
 }
 public Task TaintKey(ServiceApiKey key, int taintDays = 7, string reason = "")
 {
     return(Task.CompletedTask);
 }
 public ServiceApiKey AddOrUpdate(ServiceApiKey entity)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
 public ServiceWrapper(string requesterId, ServiceApiKey apiKey)
 {
     RequesterId = requesterId;
     ApiKey      = apiKey;
     CreateOrRotateClient(apiKey);
 }
Exemplo n.º 8
0
 public ServicesApiKeyLog(ServiceApiKey apiKey, string requesterId, string stackTrace)
 {
     this.ApiKey      = apiKey;
     this.RequesterId = requesterId;
     this.Stack       = stackTrace;
 }