public static void AddQnaApiClient(this IServiceCollection services, QnaApiConfig config, bool disableBearerHeader = false) { config.DisableBearerHeader = disableBearerHeader; services.AddTransient <QnaApiConfig>(provider => config); services.AddHttpClient <QnaApiClient>(client => client.BaseAddress = config.BaseUri); }
public QnaApiClient(HttpClient httpClient, QnaApiConfig apiConfig) { _httpClient = httpClient; _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiConfig.GetBearerToken()); }