Skip to content

BatchHttpRequest and google-auth #375

@sbrieuc

Description

@sbrieuc

Hi,

I'm using this client library with google-auth to make calls to several Google APIs (Drive mainly), it works fine however it seems that when using a Batch request it doesn't use the credentials of each request in the batch, only the credentials from the first one.

Which means that when I impersonate two different users in two different requests in the same batch, both requests are made impersonating the first user.

For example here's how I proceed to list the files of two users:

creds_one = google.oauth2.service_account.Credentials.from_service_account_file(path_to_json, scopes=scopes, subject='user1@xxx.com')
creds_two = google.oauth2.service_account.Credentials.from_service_account_file(path_to_json, scopes=scopes, subject='user2@xxx.com')

drive_service_one = build('drive', 'v3', credentials=creds_one)
drive_service_two = build('drive', 'v3', credentials=creds_two)

_batch = BatchHttpRequest()
_batch.add(request=drive_service_one.files().list(), request_id='u1')
_batch.add(request=drive_service_two.files().list(), request_id='u2')

_batch.execute()

What I observe in this case is that both requests return the list of files from the first user.
Am I missing something here ?

Thanks

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.triage meI really want to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions