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'))
此代碼工作正常,似乎測試令牌傳送到服務器。但是,我不能想出一個如何在服務器端獲取令牌並檢查它的解決方案。