private async Task <string> DoGetAccessToken(ReloadlyService service)
        {
            var operation =
                new OAuth2Operation(
                    ((ReloadlyHttpClient)HttpClient).Clone(true), AuthenticationApi.BaseUri, ClientId !, ClientSecret !,
                    service);

            var tokenHolder = await operation.GetAccessTokenAsync();

            return(tokenHolder.AccessToken !);
        }
Beispiel #2
0
        public OAuth2Operation(
            IReloadlyHttpClient httpClient,
            Uri baseUri, string clientId, string clientSecret,
            ReloadlyService service)
        {
            if (string.IsNullOrWhiteSpace(clientId))
            {
                throw new ArgumentNullException(nameof(clientId));
            }
            if (string.IsNullOrWhiteSpace(clientSecret))
            {
                throw new ArgumentNullException(nameof(clientSecret));
            }

            _httpClient   = httpClient;
            _baseUri      = baseUri;
            _clientId     = clientId;
            _service      = service;
            _clientSecret = clientSecret;
        }
        public AuthenticationApi(
            IHttpClientFactory httpClientFactory,
            string clientId, string clientSecret,
            ReloadlyService service)
        {
            if (string.IsNullOrWhiteSpace(clientId))
            {
                throw new ArgumentNullException(nameof(clientId));
            }

            if (string.IsNullOrWhiteSpace(clientSecret))
            {
                throw new ArgumentNullException(nameof(clientSecret));
            }

            _httpClient = new ReloadlyHttpClient(httpClientFactory, ReloadlyApiVersion.AirtimeV1);

            _clientId     = clientId;
            _clientSecret = clientSecret;
            _service      = service;
        }