public async ValueTask <T> GetAsync <T>(string serviceName, string endpoint, EndpointAuthenticationType endpointAuthenticationType, CancellationToken cancellationToken) { if (!_serviceAddresses.ContainsKey(serviceName)) { throw new InvalidOperationException("Service is not registered in service discovery."); } var uri = $"{_serviceAddresses[serviceName]}/{endpoint}"; var accessToken = endpointAuthenticationType switch { EndpointAuthenticationType.Profile => await _accessTokenProvider.GetProfileTokenAsync(cancellationToken).ConfigureAwait(false), EndpointAuthenticationType.Service => await _accessTokenProvider.GetServiceTokenAsync(cancellationToken).ConfigureAwait(false), _ => null }; return(await _httpClient.GetAsync <T>(uri, accessToken, cancellationToken) .ConfigureAwait(false)); }