【发布时间】:2021-11-17 23:58:57
【问题描述】:
我写了以下代码:
def check_token(token):
response = requests.get("https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com")
key_list = response.json()
decoded_token = jwt.decode(token, key=key_list, algorithms=["RS256"])
print(f"Decoded token : {decoded_token}")
我正在尝试解码 firebase 客户端提供的 token 以在服务器端进行验证。
上面的代码抛出了以下异常:
TypeError: Expecting a PEM-formatted key.
我试图不将列表传递给jwt.decode 方法,只传递关键内容,并且我有一个比库could not deserialize the Key 更大的错误。
我正在关注这个answer,但我收到了这个错误。
是requests 转换问题吗?我做错了什么?
【问题讨论】:
标签: python firebase firebase-authentication jwt pyjwt