felix.yuan
10/31/2023, 2:03 AMdebug_error_string = "UNKNOWN:failed to connect to all addresses; last error: UNKNOWN: ipv4:192.168.0.7:50051: Endpoint is neither UDS or TCP loopback address. {created_time:"2023-10-31T01:32:36.85531+00:00", grpc_status:14}"
. Any clue on this?Joey
10/31/2023, 2:06 AMJoey
10/31/2023, 2:07 AMclass TokenAuthorization(ClientInterceptor):
def __init__(self, token: str):
self._token = token
def intercept(
self,
method: Callable,
request_or_iterator: Any,
call_details: grpc.ClientCallDetails,
):
metadata = [("authorization", f"Bearer {self._token}")]
if call_details.metadata is not None:
metadata = metadata.extend(call_details.metadata)
print("final metadata: ", metadata)
new_details = ClientCallDetails(
call_details.method,
call_details.timeout,
metadata,
call_details.credentials,
call_details.wait_for_ready,
call_details.compression,
)
return method(request_or_iterator, new_details)
class CustomClient(Client):
def __init__(
self,
target: str,
token: str,
options=None,
compression=None,
):
fake_credentials = grpc.local_channel_credentials()
super().__init__(target, fake_credentials, options, compression)
auth_interceptor = TokenAuthorization(token)
insecure_channel = grpc.insecure_channel(target, options, compression)
channel = grpc.intercept_channel(insecure_channel, auth_interceptor)
SchemaServiceStub.__init__(self, channel)
PermissionsServiceStub.__init__(self, channel)
felix.yuan
10/31/2023, 2:14 AMJoey
10/31/2023, 2:16 AMfelix.yuan
10/31/2023, 2:18 AMJoey
10/31/2023, 2:18 AMJoey
10/31/2023, 2:18 AMfelix.yuan
10/31/2023, 2:19 AMfelix.yuan
10/31/2023, 2:20 AMfelix.yuan
10/31/2023, 2:21 AM--grpc-tls-cert-path
and --grpc-tls-key-path
?Joey
10/31/2023, 2:22 AMJoey
10/31/2023, 2:22 AMfelix.yuan
10/31/2023, 2:24 AMJoey
10/31/2023, 9:27 PMcorkrean
10/31/2023, 9:29 PMtheconductor
11/17/2023, 9:14 PMCustomClient
Joey provided and it's worked like a charm so far, thank you for that! I needed it to just do some preliminary testing of spicedb.
Unfortunately, I noticed that it still gave the original "neither UDS or TCP" if I used the new BulkCheckPermission
api – any idea as to why? Every other call I've made has gone throughJoey
11/17/2023, 9:46 PMtheconductor
11/17/2023, 10:04 PMtheconductor
12/01/2023, 10:39 PMExperimentalService
, as was already done with the SchemaService
and PermissionsService
. The final subclass looks like this:
python
class SpiceClient(Client):
def __init__(
self,
target: str,
token: str,
options=None,
compression=None,
):
fake_credentials = grpc.local_channel_credentials()
super().__init__(target, fake_credentials, options, compression)
auth_interceptor = TokenAuthorization(token)
insecure_channel = grpc.insecure_channel(target, options, compression)
channel = grpc.intercept_channel(insecure_channel, auth_interceptor)
SchemaServiceStub.__init__(self, channel)
PermissionsServiceStub.__init__(self, channel)
# ADDED THESE TWO LINES
ExperimentalServiceStub.__init__(self, channel)
WatchServiceStub.__init__(self, channel)
Joey
12/01/2023, 10:41 PM