diff options
author | arithmetic1728 <58957152+arithmetic1728@users.noreply.github.com> | 2020-09-03 11:15:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-03 11:15:13 -0700 |
commit | 8f8ee7879e4f834f3c676e535ffc41b5b9b2de62 (patch) | |
tree | 105dbd92560cb4f2301ca1d4cdec324ba65299b6 | |
parent | 622931721ce34839d630aa1e974c7d8f47b5d25e (diff) | |
download | python-api-core-8f8ee7879e4f834f3c676e535ffc41b5b9b2de62.tar.gz |
fix: only add quota project id if supported (#75)
-rw-r--r-- | google/api_core/grpc_helpers.py | 2 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | tests/asyncio/test_grpc_helpers_async.py | 2 | ||||
-rw-r--r-- | tests/unit/test_grpc_helpers.py | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index dfc8442..0ccbe12 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -216,7 +216,7 @@ def _create_composite_credentials( else: credentials, _ = google.auth.default(scopes=scopes) - if quota_project_id: + if quota_project_id and isinstance(credentials, google.auth.credentials.CredentialsWithQuotaProject): credentials = credentials.with_quota_project(quota_project_id) request = google.auth.transport.requests.Request() @@ -31,7 +31,7 @@ release_status = "Development Status :: 5 - Production/Stable" dependencies = [ "googleapis-common-protos >= 1.6.0, < 2.0dev", "protobuf >= 3.12.0", - "google-auth >= 1.19.1, < 2.0dev", + "google-auth >= 1.21.1, < 2.0dev", "requests >= 2.18.0, < 3.0.0dev", "setuptools >= 34.0.0", "six >= 1.10.0", diff --git a/tests/asyncio/test_grpc_helpers_async.py b/tests/asyncio/test_grpc_helpers_async.py index 924a74c..766e11a 100644 --- a/tests/asyncio/test_grpc_helpers_async.py +++ b/tests/asyncio/test_grpc_helpers_async.py @@ -369,7 +369,7 @@ def test_create_channel_explicit_with_quota_project(grpc_secure_channel, composi target = "example.com:443" composite_creds = composite_creds_call.return_value - credentials = mock.create_autospec(google.auth.credentials.Credentials, instance=True) + credentials = mock.create_autospec(google.auth.credentials.CredentialsWithQuotaProject, instance=True) channel = grpc_helpers_async.create_channel( target, credentials=credentials, quota_project_id="project-foo" diff --git a/tests/unit/test_grpc_helpers.py b/tests/unit/test_grpc_helpers.py index f8fed40..d6ec60a 100644 --- a/tests/unit/test_grpc_helpers.py +++ b/tests/unit/test_grpc_helpers.py @@ -341,7 +341,7 @@ def test_create_channel_explicit_with_quota_project(grpc_secure_channel, composi target = "example.com:443" composite_creds = composite_creds_call.return_value - credentials = mock.create_autospec(google.auth.credentials.Credentials, instance=True) + credentials = mock.create_autospec(google.auth.credentials.CredentialsWithQuotaProject, instance=True) channel = grpc_helpers.create_channel( target, |