写grpc接口,总是报参数有问题,不太懂代码,请大家帮忙看看哈
方法:
def test_AuthenticateRequest(self):
# token=test_loginRequest
# print(token)
test_loginRequest='eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsicmVzMiJdLCJ1c2VyX25hbWUiOiIrODYxODIwNzEwMjM0OCIsInNjb3BlIjpbImFsbCJdLCJleHAiOjE2NDU3Mzg0MDcsInVzZXIiOnsiaWQiOjUxMTM3NTc4NTkxMTgxMzEyMCwibW9iaWxlIjoiKzg2MTgyMDcxMDIzNDgiLCJlbWFpbCI6bnVsbCwidXNlcm5hbWUiOiIrODYxODIwNzEwMjM0OCIsInNvdXJjZSI6MiwiZW5hYmxlZCI6dHJ1ZSwiYWNjb3VudE5vbkV4cGlyZWQiOnRydWUsImFjY291bnROb25Mb2NrZWQiOnRydWUsImNyZWRlbnRpYWxzTm9uRXhwaXJlZCI6dHJ1ZSwiYXV0aG9yaXRpZXMiOlt7ImF1dGhvcml0eSI6ImFkbWluIn1dfSwiYXV0aG9yaXRpZXMiOlsiYWRtaW4iXSwianRpIjoiMWNmNGJiNDgtNDc0MC00MzRiLThmOTMtMDc5ZTRiZDc5NGViIiwiY2xpZW50X2lkIjoiYmFibyJ9.e6n-jgNiCTiBNMcW-NwBu7hYiJS0L8IdGK7tL96H7T9YzKbjr-Rb5iOyMd7KCNAUUDaTwg_wdT5aSTFqLC3zmUpFIyndJiiduxPhXlGGyl0UCXkFvxECeL_C0dDIV8KyYTkAr41TshY6xc3hEYTiJQKxteveSbkFDI0gFpDWXx04sWjOyA8x6r9BcCFi9N4BplzCfxvv_ESD5iAtLhXk3wLDM5PKA1pSjAOhWjKQfDWNrREZO0y52BcM3ifKgqdQCjnVyJPynzjo8zsjVk9L_7VVK2TrIPU9KB3AEYzbnjGGkmU8jbwzFyTFHkvJSFSIwZahB-IDhEwgGYZ9VtYm5Q'
headers={
'x-client-version': '200130001',
'x-client-name': 'io.jojoy',
# 'x-device-os': 'android',
'x-timezone-offset': '28800',
# 'x-instance-id': '',
# 'x-client-channel': 'unknown',
'x-app-name': 'Jojoy',
'x-locale': 'en',
# 'x-biz-token': '',
# 'Authorization': 'Bearer xxx'
# 'Authorization': 'Basic YmFibzoxMjM0NTY=',
# 'x-biz-token': ''
}
# 连接 rpc 服务器
channel = grpc.insecure_channel('grpc-test.happymod.cool:443')
#调用grpc服务
stub = user_pb2_grpc.UserServiceStub(channel)
#发送数据、接收数据
response = stub.Authenticate(user_pb2.AuthenticateRequest(access_token=test_loginRequest),metadata=headers)
print("Greeter client received: " + response.message)
报错:
response = stub.Authenticate(user_pb2.AuthenticateRequest(access_token=test_loginRequest),metadata=headers)
E ValueError: too many values to unpack (expected 2)