如何在 Python 中解码 Apple 在注册过程中发送的 id_token?
我已经尝试过(从这里/sf/answers/4613660271/)
import jwt
decoded = jwt.decode(token, options={"verify_signature": False})
Run Code Online (Sandbox Code Playgroud)
我收到错误:
jwt.exceptions.InvalidAudienceError: Invalid audience
Run Code Online (Sandbox Code Playgroud)
如果我将 id_token 复制粘贴到 jwt.io 页面https://jwt.io/,那么它会正确地将其解码为所有部分(标头、带有 aud 的有效负载、子等),因此令牌本身是正确的,我有我需要的所有信息。
当我提供预期的 aud 值时它会起作用。aud 与您首次调用 Apple 登录时提供的 clientId 相同(https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/configuring_your_webpage_for_sign_in_with_apple),与 Apple 控制台中的 Identifier 相同你设置它的地方。
必须有一种方法可以在不提供 aud 的情况下做到这一点,因为这个 wbeage https://jwt.io/可以做到这一点。然而,也许不在Python中......
import jwt
decoded = jwt.decode(token, audience="<your app's>",options={"verify_signature": False})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3622 次 |
| 最近记录: |