Make secure_authorized_channel pass kwargs to grpc.secure_channel (#90)
diff --git a/google/auth/transport/grpc.py b/google/auth/transport/grpc.py
index 1e02b38..4062972 100644
--- a/google/auth/transport/grpc.py
+++ b/google/auth/transport/grpc.py
@@ -62,7 +62,7 @@
def secure_authorized_channel(
- credentials, request, target, ssl_credentials=None):
+ credentials, request, target, ssl_credentials=None, **kwargs):
"""Creates a secure authorized gRPC channel.
This creates a channel with SSL and :class:`AuthMetadataPlugin`. This
@@ -98,6 +98,7 @@
target (str): The host and port of the service.
ssl_credentials (grpc.ChannelCredentials): Optional SSL channel
credentials. This can be used to specify different certificates.
+ kwargs: Additional arguments to pass to :func:`grpc.secure_channel`.
Returns:
grpc.Channel: The created gRPC channel.
@@ -115,4 +116,4 @@
composite_credentials = grpc.composite_channel_credentials(
ssl_credentials, google_auth_credentials)
- return grpc.secure_channel(target, composite_credentials)
+ return grpc.secure_channel(target, composite_credentials, **kwargs)
diff --git a/tests/transport/test_grpc.py b/tests/transport/test_grpc.py
index 84e4b56..15a301f 100644
--- a/tests/transport/test_grpc.py
+++ b/tests/transport/test_grpc.py
@@ -82,7 +82,7 @@
target = 'example.com:80'
channel = google.auth.transport.grpc.secure_authorized_channel(
- credentials, request, target)
+ credentials, request, target, options=mock.sentinel.options)
# Check the auth plugin construction.
auth_plugin = metadata_call_credentials.call_args[0][0]
@@ -101,7 +101,8 @@
# Check the channel call.
secure_channel.assert_called_once_with(
- target, composite_channel_credentials.return_value)
+ target, composite_channel_credentials.return_value,
+ options=mock.sentinel.options)
assert channel == secure_channel.return_value