# jose.exceptions.JWSSignatureError: 签名验证失败。

- **ID:** `python/fastapi-jwt-decode-invalid-signature`
- **领域:** python
- **类别:** auth_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

JWT 使用的签名密钥与验证时的密钥不同，或算法不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |
| 5.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   payload = jwt.decode(token, SECRET_KEY, algorithms=['HS256'])
   ```
2. **** (93% 成功率)
   ```
   SECRET_KEY = os.environ['JWT_SECRET']  # same in issuer and verifier
   ```

## 无效尝试

- **** — Disables auth entirely; severe security hole. (99% 失败率)
- **** — Accepts invalid tokens; security bypass. (98% 失败率)
