Bandaid over differences in the C API for Python credentials
diff --git a/src/python/grpcio/grpc/_adapter/_intermediary_low.py b/src/python/grpcio/grpc/_adapter/_intermediary_low.py
index e2feec6..5634c20 100644
--- a/src/python/grpcio/grpc/_adapter/_intermediary_low.py
+++ b/src/python/grpcio/grpc/_adapter/_intermediary_low.py
@@ -253,10 +253,10 @@
class ClientCredentials(object):
- """Adapter from old _low.ClientCredentials interface to new _low.ClientCredentials."""
+ """Adapter from old _low.ClientCredentials interface to new _low.ChannelCredentials."""
def __init__(self, root_certificates, private_key, certificate_chain):
- self._internal = _low.ClientCredentials.ssl(root_certificates, private_key, certificate_chain)
+ self._internal = _low.ChannelCredentials.ssl(root_certificates, private_key, certificate_chain)
class ServerCredentials(object):
diff --git a/src/python/grpcio/grpc/_adapter/_low.py b/src/python/grpcio/grpc/_adapter/_low.py
index 70ceb2a..57146aa 100644
--- a/src/python/grpcio/grpc/_adapter/_low.py
+++ b/src/python/grpcio/grpc/_adapter/_low.py
@@ -33,7 +33,8 @@
_USER_AGENT = 'Python-gRPC-{}'.format(_grpcio_metadata.__version__)
-ClientCredentials = _c.ClientCredentials
+ChannelCredentials = _c.ChannelCredentials
+CallCredentials = _c.CallCredentials
ServerCredentials = _c.ServerCredentials
diff --git a/src/python/grpcio/grpc/_adapter/_types.py b/src/python/grpcio/grpc/_adapter/_types.py
index 5470d2d..ca0fa06 100644
--- a/src/python/grpcio/grpc/_adapter/_types.py
+++ b/src/python/grpcio/grpc/_adapter/_types.py
@@ -323,6 +323,14 @@
"""
return None
+ def set_credentials(self, creds):
+ """Set per-call credentials.
+
+ Args:
+ creds (CallCredentials): Credentials to be set for this call.
+ """
+ return None
+
class Channel:
__metaclass__ = abc.ABCMeta
@@ -334,7 +342,7 @@
Args:
target (str): ...
args (sequence of 2-sequence of str, (str|integer)): ...
- credentials (ClientCredentials): If None, create an insecure channel,
+ credentials (ChannelCredentials): If None, create an insecure channel,
else create a secure channel using the client credentials.
"""
diff --git a/src/python/grpcio/grpc/beta/interfaces.py b/src/python/grpcio/grpc/beta/interfaces.py
index 07c8618..d4ca565 100644
--- a/src/python/grpcio/grpc/beta/interfaces.py
+++ b/src/python/grpcio/grpc/beta/interfaces.py
@@ -100,8 +100,11 @@
disable_compression: A boolean indicating whether or not compression should
be disabled for the request object of the RPC. Only valid for
request-unary RPCs.
- credentials: A ClientCredentials object to use for the invoked RPC.
+ credentials: Reserved for gRPC per-call credentials. The type for this does
+ not exist yet at the Python level.
"""
+ if credentials is not None:
+ raise ValueError('`credentials` is a reserved argument')
return GRPCCallOptions(disable_compression, None, credentials)
diff --git a/src/python/grpcio_test/grpc_test/beta/_beta_features_test.py b/src/python/grpcio_test/grpc_test/beta/_beta_features_test.py
index fad57da..5916a9e 100644
--- a/src/python/grpcio_test/grpc_test/beta/_beta_features_test.py
+++ b/src/python/grpcio_test/grpc_test/beta/_beta_features_test.py
@@ -181,24 +181,21 @@
self._server.stop(test_constants.SHORT_TIMEOUT).wait()
def test_unary_unary(self):
- call_options = interfaces.grpc_call_options(
- disable_compression=True, credentials=self._client_credentials)
+ call_options = interfaces.grpc_call_options(disable_compression=True)
response = getattr(self._dynamic_stub, _UNARY_UNARY)(
_REQUEST, test_constants.LONG_TIMEOUT, protocol_options=call_options)
self.assertEqual(_RESPONSE, response)
self.assertIsNotNone(self._servicer.peer())
def test_unary_stream(self):
- call_options = interfaces.grpc_call_options(
- disable_compression=True, credentials=self._client_credentials)
+ call_options = interfaces.grpc_call_options(disable_compression=True)
response_iterator = getattr(self._dynamic_stub, _UNARY_STREAM)(
_REQUEST, test_constants.LONG_TIMEOUT, protocol_options=call_options)
self._servicer.block_until_serviced()
self.assertIsNotNone(self._servicer.peer())
def test_stream_unary(self):
- call_options = interfaces.grpc_call_options(
- credentials=self._client_credentials)
+ call_options = interfaces.grpc_call_options()
request_iterator = _BlockingIterator(iter((_REQUEST,)))
response_future = getattr(self._dynamic_stub, _STREAM_UNARY).future(
request_iterator, test_constants.LONG_TIMEOUT,
@@ -212,8 +209,7 @@
self.assertEqual(_RESPONSE, response_future.result())
def test_stream_stream(self):
- call_options = interfaces.grpc_call_options(
- credentials=self._client_credentials)
+ call_options = interfaces.grpc_call_options()
request_iterator = _BlockingIterator(iter((_REQUEST,)))
response_iterator = getattr(self._dynamic_stub, _STREAM_STREAM)(
request_iterator, test_constants.SHORT_TIMEOUT,