API 身份验证
所有 API v2 请求均需通过 Bearer token 进行身份验证。
工作原理
- 在设置 > API 密钥中生成 API 密钥
- 在每个请求的
Authorization请求头中包含该密钥:
Authorization: Bearer YOUR_API_KEY_HERE
Example (cURL)
curl -X GET "https://yourdomain.com/api/v2/submissions" \
-H "Authorization: Bearer fp_key_abc123xyz789" \
-H "Accept: application/json"
Example (JavaScript)
const response = await fetch('https://yourdomain.com/api/v2/submissions', {
headers: {
'Authorization': 'Bearer fp_key_abc123xyz789',
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
const data = await response.json();
Example (PHP)
$client = new \GuzzleHttp\Client();
$response = $client->get('https://yourdomain.com/api/v2/submissions', [
'headers' => [
'Authorization' => 'Bearer fp_key_abc123xyz789',
'Accept' => 'application/json',
]
]);
$data = json_decode($response->getBody(), true);
Example (Python)
import requests
headers = {
'Authorization': 'Bearer fp_key_abc123xyz789',
'Accept': 'application/json'
}
response = requests.get('https://yourdomain.com/api/v2/submissions', headers=headers)
data = response.json()
安全性
| 特性 | 详情 |
|---|---|
| 存储 | 密钥以 SHA256 哈希形式存储在数据库中 |
| 作用域 | 密钥仅限特定租户使用 |
| 追踪 | 每次使用时更新 last_used_at 时间戳 |
| 过期 | 密钥可设置可选的过期日期 |
| 撤销 | 密钥可从设置中立即撤销 |
API 密钥管理
| 操作 | 方式 |
|---|---|
| 创建 | 设置 > API 密钥 > 创建新密钥 |
| 查看 | 查看密钥名称、创建日期、最后使用日期 |
| 撤销 | 点击撤销以永久禁用密钥 |
注意
完整密钥仅在创建时显示一次。请妥善保存。如遗失,请撤销并创建新密钥。