Class Client (2.5.0)

Client(credentials=None,_http=None,client_options=None)

Client to bundle configuration needed for API requests.

Storescredentials and an HTTP object so that subclassescan pass them along to a connection class.

If no value is passed in for_http, arequests.Session objectwill be created and authorized with thecredentials. If not, thecredentials and_http need not be related.

Callers and subclasses may seek to use the private key fromcredentials to sign data.

Parameters

NameDescription
credentialsgoogle.auth.credentials.Credentials

(Optional) The OAuth2 Credentials to use for this client. If not passed (and if no_http object is passed), falls back to the default inferred from the environment.

client_optionsgoogle.api_core.client_options.ClientOptions

(Optional) Custom options for the client.

_httprequests.Session

(Optional) HTTP object to make requests. Can be any object that definesrequest() with the same interface asrequests.Session.request. If not passed, an_http object is created that is bound to thecredentials for the current object. This parameter should be considered private, and could change in the future.

Methods

__getstate__

__getstate__()

Explicitly state that clients are not pickleable.

close

close()

Clean up transport, if set.

Suggested use:

import contextlibwith contextlib.closing(client):  # closes on exit    do_something_with(client)

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-30 UTC.