Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use insecure grpc channel with emulator #946

Merged
merged 6 commits into from
Apr 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
don't use credentials with emulator
  • Loading branch information
daniel-sanche committed Mar 20, 2024
commit 9bbd7a562d8a6e159b1c5c824f6a5da5621b4ecf
14 changes: 2 additions & 12 deletions google/cloud/bigtable/client.py
Expand Up @@ -214,7 +214,7 @@ def _get_scopes(self):
return scopes

def _emulator_channel(self, transport, options):
"""Create a channel using self._credentials
"""Create a channelfor use with the Bigtable emulator.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in channelfor


Insecure channels are used for the emulator as secure channels
cannot be used to communicate on some environments.
Expand All @@ -224,21 +224,11 @@ def _emulator_channel(self, transport, options):
grpc.Channel or grpc.aio.Channel
"""
# Note: this code also exists in the firestore client.

# Default the token to a non-empty string, in this case "owner".
token = "owner"
if self._credentials is not None and self._credentials.id_token is not None:
token = self._credentials.id_token
options.append(("Authorization", f"Bearer {token}"))
if "GrpcAsyncIOTransport" in str(transport.__name__):
channel_fn = grpc.aio.insecure_channel
else:
channel_fn = grpc.insecure_channel
return channel_fn(
self._emulator_host,
self._local_composite_credentials(),
options=options,
)
return channel_fn(self._emulator_host, options=options)

def _create_gapic_client_channel(self, client_class, grpc_transport):
if self._emulator_host is not None:
Expand Down