# Fixing Google BigQuery Auth Proxying

> Source: <https://dev.to/snargledorf/fixing-google-bigquery-auth-proxying-2hb7>
> Published: 2026-05-22 20:15:08+00:00

builder.Credential = credential;
- Fails to route authentication traffic through the proxy.builder.GoogleCredential = credential;
- Successfully routes OAuth token requests through the proxy.If your C# application runs behind a proxy, you have probably run into an annoying issue with the Google BigQuery client libraries: your BigQuery query calls route through the proxy perfectly by setting the HttpClientFactory
property on the BigQueryClientBuilder
, but the authentication and token refresh requests ignore the proxy entirely and attempt to hit the standard network, causing timeouts.
To resolve this, set a proxied GoogleCredential
to the GoogleCredential
property instead of the Credential
property on the client builder.
Example code:
using System.Net;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Http;
using Google.Cloud.BigQuery.V2;
// 1. Configure your proxy
IWebProxy proxySettings = new WebProxy("http://your-proxy-host:8080", bypassOnLocal: true)
{
Credentials = new NetworkCredential("username", "password")
};
// 2. Wrap it inside Google's API HttpClientFactory
HttpClientFactory proxyClientFactory = HttpClientFactory.ForProxy(proxySettings);
// 3. Load credentials and create a new credential using the proxied http client factory
GoogleCredential credential = await GoogleCredential.FromFileAsync("path/to/service-account.json");
credential = credential.CreateWithHttpClientFactory(proxyClientFactory);
// 4. Construct the client
BigQueryClient bigQueryClient = new BigQueryClientBuilder
{
ProjectId = "your-google-cloud-project-id",
HttpClientFactory = proxyClientFactory, // Proxies BigQuery data calls
GoogleCredential = credential // CRITICAL: Proxies Auth/token calls
}.Build();
