Skip to content

Docs request: how to use Client._http #1287

@jamesbraza

Description

@jamesbraza

Is your feature request related to a problem? Please describe.

I am trying to figure out how to use httpx==0.27.0 with google.cloud.storage.Client (google-cloud-storage==2.16.0). I think I need to use Client._http:

import google.auth
import httpx
from google.cloud.storage import Client

http = httpx.Client(
    transport=httpx.HTTPTransport(
        limits=httpx.Limits(
            max_connections=MAX_THREADS, max_keepalive_connections=MAX_THREADS
        )
    )
)
# Emulating https://github.com/googleapis/google-auth-library-python/blob/v2.29.0/google/auth/transport/requests.py#L400
http.is_mtls = False  # type: ignore[attr-defined]
# Emulating https://github.com/googleapis/python-cloud-core/blob/v2.4.1/google/cloud/client/__init__.py#L178
credentials, project = google.auth.default(scopes=Client.SCOPE)
return Client(project=project, credentials=credentials, _http=http)

However, using this I am getting an error:

E google.api_core.exceptions.Unauthorized: 401 GET https://storage.googleapis.com/storage/v1/b/foo?projection=noAcl&prettyPrint=false: Anonymous caller does not have storage.buckets.get access to the Google Cloud Storage bucket. Permission 'storage.buckets.get' denied on resource (or it may not exist).

Describe the solution you'd like

It would be nice to support docs on how to integrate httpx with google-cloud-storage using _http.

Describe alternatives you've considered

N/a

Additional context

N/a

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/python-storage API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions