0
我试图实现与GRPC定制的基于令牌的身份验证方案,我必须在客户端下面的代码:如何在服务器端获取身份验证令牌?
with open('server.crt', 'rb') as f:
trusted_certs = f.read()
credentials = grpc.ssl_channel_credentials(root_certificates=trusted_certs)
composite_credentials = grpc.composite_channel_credentials(credentials, grpc.access_token_call_credentials("test_token"))
channel = grpc.secure_channel('{}:{}'.format('localhost', 50051), composite_credentials)
stub = helloworld_pb2_grpc.GreeterStub(channel)
response = stub.SayHello(helloworld_pb2.HelloRequest(name='test'))
此代码工作正常,似乎测试令牌传送到服务器。但是,我不能想出一个如何在服务器端获取令牌并检查它的解决方案。