protected async override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var token = await _tokenServiceClient.GetToken();

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
            return(await base.SendAsync(request, cancellationToken));
        }
        /// <summary>
        /// Get an auth token
        /// </summary>
        /// <returns></returns>
        private async Task <TokenResponse> GetToken()
        {
            var tokenRequest = new TokenRequest
            {
                RequestUri      = RemittanceRequestUri.Token,
                ApiKey          = remittanceConfig.ApiKey,
                SubscriptionKey = remittanceConfig.SubscriptionKey,
                UserId          = remittanceConfig.UserId
            };

            var token = await tokenClient.GetToken(tokenRequest);

            return(token.Data);
        }
        /// <summary>
        /// Get an auth token
        /// </summary>
        /// <returns></returns>
        private async Task <TokenResponse> GetToken()
        {
            var tokenRequest = new TokenRequest
            {
                RequestUri      = DisbursementsRequestUri.Token,
                ApiKey          = disbursementConfig.ApiKey,
                SubscriptionKey = disbursementConfig.SubscriptionKey,
                UserId          = disbursementConfig.UserId
            };

            var token = await tokenClient.GetToken(tokenRequest);

            return(token.Data);
        }
        public async Task GetTokenTest()
        {
            // Arrange
            var id = "token-id";

            _stripe.Get(Arg.Is <StripeRequest <Token> >(a => a.UrlPath == "tokens/" + id), _cancellationToken)
            .Returns(Task.FromResult(new StripeResponse <Token>()));

            // Act
            var response = await _client.GetToken(id, _cancellationToken);

            // Assert
            response.Should().NotBeNull();
        }
Example #5
0
        private async void SetAuthorization()
        {
            var tokenResponse = await _tokenClient.GetToken();

            _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResponse.AccessToken);
        }
        public async Task <IActionResult> Post()
        {
            var resultToken = await _token.GetToken();

            return(Ok(resultToken));
        }