public async Task <Configuration> BuildClientSessionConfiguration(CancellationToken cancellationToken = default) { var session = await _cachingService.GetClientSession(); if (session.HasValue) { return(new Configuration { AccessToken = session.Value }); } try { var auth = new AuthorizationApi(); var fintechSession = await auth.GetTokenAsync("client_credentials", _settings.ClientId, _settings.Secret, cancellationToken : cancellationToken); await _cachingService.SaveClientSession(fintechSession._AccessToken); return(new Configuration { AccessToken = fintechSession._AccessToken }); } catch (ApiException ex) { _logger.LogError(ex.ToString()); } return(null); }
public async Task <AccessToken> Login(string id, string password, CancellationToken cancellationToken = default) { try { var auth = new AuthorizationApi(); return(await auth.GetTokenAsync("password", _settings.ClientId, _settings.Secret, null, id, password, cancellationToken)); } catch (ApiException ex) { _logger.LogError(ex.ToString()); } return(null); }