Example #1
0
        /// <inheritdoc/>
        public async Task <TokenResponse> RefreshUserAccessTokenAsync(
            string refreshToken,
            UserAccessTokenParameters parameters = null,
            CancellationToken cancellationToken  = default)
        {
            _logger.LogDebug("Refreshing refresh token: {token}", refreshToken);

            parameters ??= new UserAccessTokenParameters();

            var requestDetails = await _configService.GetRefreshTokenRequestAsync(parameters);

            requestDetails.RefreshToken = refreshToken;

#if NET5_0
            requestDetails.Options.TryAdd(AccessTokenManagementDefaults.AccessTokenParametersOptionsName, parameters);
#elif NETCOREAPP3_1
            requestDetails.Properties[AccessTokenManagementDefaults.AccessTokenParametersOptionsName] = parameters;
#endif

            if (!string.IsNullOrEmpty(parameters.Resource))
            {
                requestDetails.Resource.Add(parameters.Resource);
            }

            var httpClient = _httpClientFactory.CreateClient(AccessTokenManagementDefaults.BackChannelHttpClientName);
            return(await httpClient.RequestRefreshTokenAsync(requestDetails, cancellationToken));
        }
        /// <inheritdoc/>
        public async Task <TokenResponse> RefreshUserAccessTokenAsync(string refreshToken)
        {
            var requestDetails = await _configService.GetRefreshTokenRequestAsync();

            requestDetails.RefreshToken = refreshToken;

            return(await _httpClient.RequestRefreshTokenAsync(requestDetails));
        }