为什么这个设定了时间的令牌没有一点用啊

关注让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言问题分析:
import time
import jwt
# 生成令牌
token = jwt.encode({"user_id": 12345, "exp": time.time() + 3600}, "secret_key", algorithm="HS256")
# 解析令牌
payload = jwt.decode(token, "secret_key", algorithms=["HS256"])
# 打印令牌的过期时间
print(payload["exp"])
import jwt
from flask import request
# 从请求头中获取令牌
token = request.headers.get("Authorization")
# 解析令牌
payload = jwt.decode(token, "secret_key", algorithms=["HS256"])
# 打印用户ID
print(payload["user_id"])
import jwt
# 生成令牌
token = jwt.encode({"user_id": 12345}, "wrong_secret_key", algorithm="HS256")
# 解析令牌
try:
payload = jwt.decode(token, "secret_key", algorithms=["HS256"])
print(payload)
except jwt.ExpiredSignatureError:
print("令牌已过期")
except jwt.InvalidTokenError:
print("令牌不合法")