Skip to content

Commit 48a2676

Browse files
committed
fix: set creds only if transport not provided
1 parent 8adb133 commit 48a2676

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

google/cloud/pubsub_v1/publisher/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ def __init__(
132132
kwargs["client_options"] = {
133133
"api_endpoint": os.environ.get("PUBSUB_EMULATOR_HOST")
134134
}
135-
kwargs["credentials"] = AnonymousCredentials()
135+
# Configure credentials directly to transport, if provided.
136+
if not kwargs["transport"]:
137+
kwargs["credentials"] = AnonymousCredentials()
136138

137139
# For a transient failure, retry publishing the message infinitely.
138140
self.publisher_options = types.PublisherOptions(*publisher_options)

google/cloud/pubsub_v1/subscriber/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def __init__(
8585
kwargs["client_options"] = {
8686
"api_endpoint": os.environ.get("PUBSUB_EMULATOR_HOST")
8787
}
88-
kwargs["credentials"] = AnonymousCredentials()
88+
# Configure credentials directly to transport, if provided.
89+
if not kwargs["transport"]:
90+
kwargs["credentials"] = AnonymousCredentials()
8991

9092
# Instantiate the underlying GAPIC client.
9193
super().__init__(**kwargs)

0 commit comments

Comments
 (0)