Skip to content

Commit 8f8ee78

Browse files
fix: only add quota project id if supported (#75)
1 parent 6229317 commit 8f8ee78

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

google/api_core/grpc_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def _create_composite_credentials(
216216
else:
217217
credentials, _ = google.auth.default(scopes=scopes)
218218

219-
if quota_project_id:
219+
if quota_project_id and isinstance(credentials, google.auth.credentials.CredentialsWithQuotaProject):
220220
credentials = credentials.with_quota_project(quota_project_id)
221221

222222
request = google.auth.transport.requests.Request()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
dependencies = [
3232
"googleapis-common-protos >= 1.6.0, < 2.0dev",
3333
"protobuf >= 3.12.0",
34-
"google-auth >= 1.19.1, < 2.0dev",
34+
"google-auth >= 1.21.1, < 2.0dev",
3535
"requests >= 2.18.0, < 3.0.0dev",
3636
"setuptools >= 34.0.0",
3737
"six >= 1.10.0",

tests/asyncio/test_grpc_helpers_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def test_create_channel_explicit_with_quota_project(grpc_secure_channel, composi
369369
target = "example.com:443"
370370
composite_creds = composite_creds_call.return_value
371371

372-
credentials = mock.create_autospec(google.auth.credentials.Credentials, instance=True)
372+
credentials = mock.create_autospec(google.auth.credentials.CredentialsWithQuotaProject, instance=True)
373373

374374
channel = grpc_helpers_async.create_channel(
375375
target, credentials=credentials, quota_project_id="project-foo"

tests/unit/test_grpc_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def test_create_channel_explicit_with_quota_project(grpc_secure_channel, composi
341341
target = "example.com:443"
342342
composite_creds = composite_creds_call.return_value
343343

344-
credentials = mock.create_autospec(google.auth.credentials.Credentials, instance=True)
344+
credentials = mock.create_autospec(google.auth.credentials.CredentialsWithQuotaProject, instance=True)
345345

346346
channel = grpc_helpers.create_channel(
347347
target,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy