# 错误请求：CSRF令牌缺失。

- **ID:** `python/flask-csrf-token-error`
- **领域:** python
- **类别:** auth_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

Flask-WTF或类似的CSRF保护要求表单中包含令牌，但请求中未包含。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Include the CSRF token in the form: {{ form.csrf_token }} or <input type='hidden' name='csrf_token' value='{{ csrf_token() }}'>
   ```
2. **** (90% 成功率)
   ```
   For AJAX requests, set the X-CSRFToken header using the token from the cookie.
   ```

## 无效尝试

- **** — Disabling CSRF protection globally exposes the app to CSRF attacks. (90% 失败率)
- **** — Adding a hidden field manually without the correct token value does not work. (70% 失败率)
