踩坑记录-用python解析php Laravel8生成的jwt token一直提示 Invalid audience

import jwt

def token_required(token):
    with open('storage/oauth-public.key', 'r') as f:
        public_key = f.read()
    try:
        # 尝试使用当前算法解码 token,同时指定受众
        decoded = jwt.decode(token, public_key, algorithms=['RS256'], options={"verify_aud": False})
        # print("Decoded JWT:", decoded)
        return decoded.get('jti')
    except jwt.ExpiredSignatureError:
        print("Token 已过期")
        return None
    except jwt.InvalidTokenError as e:
        print(f"无效的 token: {e}")
        return None

开始少写了个参数
options={“verify_aud”: False}

导致一直报错 Invalid audience

你可能感兴趣的:(python,php,android)