google.auth.transport package

Transport - HTTP client library support.

google.auth is designed to work with various HTTP client libraries such as urllib3 and requests. In order to work across these libraries with different interfaces some abstraction is needed.

This module provides two interfaces that are implemented by transport adapters to support HTTP libraries. Request defines the interface expected by google.auth to make requests. Response defines the interface for the return value of Request.

DEFAULT_REFRESH_STATUS_CODES = (<HTTPStatus.UNAUTHORIZED: 401>,)

Which HTTP status code indicate that credentials should be refreshed and a request should be retried.

Type:

Sequence [ int ]

DEFAULT_MAX_REFRESH_ATTEMPTS = 2

How many times to refresh the credentials and retry a request.

Type:

int

class Response[source]

Bases: object

HTTP Response data.

abstract property status

The HTTP status code.

Type:

int

abstract property headers

The HTTP response headers.

Type:

Mapping [ str, str ]

abstract property data

The response body.

Type:

bytes

class Request[source]

Bases: object

Interface for a callable that makes HTTP requests.

Specific transport implementations should provide an implementation of this that adapts their specific request / response API.

abstract __call__(url, method='GET', body=None, headers=None, timeout=None, **kwargs)[source]

Make an HTTP request.

Parameters:
  • url (str) – The URI to be requested.

  • method (str) – The HTTP method to use for the request. Defaults to ‘GET’.

  • body (bytes) – The payload / body in HTTP request.

  • headers (Mapping [ str, str ]) – Request headers.

  • timeout (Optional [ int ]) – The number of seconds to wait for a response from the server. If not specified or if None, the transport-specific default timeout will be used.

  • kwargs – Additionally arguments passed on to the transport’s request method.

Returns:

The HTTP response.

Return type:

Response

Raises:

google.auth.exceptions.TransportError – If any exception occurred.

Submodules