Google.Apis exposes a factory for creating HTTP clients with an IWebProxy. Supply it when constructing the generated service:

var proxy = new System.Net.WebProxy("http://proxy.example:8080");
proxy.Credentials = new System.Net.NetworkCredential(
    proxyUser, proxyPassword);

using var youtube = new Google.Apis.YouTube.v3.YouTubeService(
    new Google.Apis.Services.BaseClientService.Initializer
    {
        ApplicationName = "ExampleVideoClient",
        ApiKey = apiKey,
        HttpClientFactory =
            Google.Apis.Http.HttpClientFactory.ForProxy(proxy)
    });

The example uses API-key access for a supported public-data operation. Omit the proxy credentials assignment for an unauthenticated proxy. In that public-data branch, select an HTTP entry from the HTTP proxy list if public intermediaries are permitted. The proxy's account and the API key serve different endpoints.

In Google.Apis 1.73.0, BaseClientService.Initializer.HttpClientFactory is the supported creation hook. ForProxy sets the supplied proxy on clients created by that factory. Request construction, serialization and the surrounding SDK pipeline remain with the service.

Configure this before issuing requests. Replacing MessageHandler.InnerHandler on a constructed client is unnecessary for this use case and can discard other handler choices.

An OAuth credential may acquire or refresh its token through its own HTTP arrangement. Setting a service's factory does not establish how an independently created credential obtains tokens. Check that path separately if token retrieval is the operation failing through the proxy. When using GoogleCredential, keep the routed copy from CreateWithHttpClientFactory for that token work.

འབྲེལ་བའི་རྩོམ་ཡིག