Missing Authentication Token
TL;DR — "Missing Authentication Token" 意味着请求要么没有带凭证,要么打到了一个 AWS 不认识的 endpoint/方法上——对一个不存在的路径或不受支持的 HTTP 方法发请求,返回的是这个而不是 404。对 DynamoDB 而言,它几乎总是一个错误的 endpoint URL,或者一个从未被签名的请求。
含义
{"message":"Missing Authentication Token"}AWS 的 SigV4 排错指南对第一种成因说得很直白:如果 API 请求没有被签名,你可能会收到 Missing Authentication Token。反直觉的是,当路径或 HTTP 方法匹配不上任何路由时,API-Gateway 式的 endpoint 也会回同一条消息(HTTP 403)——AWS 在一个它无法路由的请求上去找认证信息,然后报告缺少令牌,而不是报“找不到”。当 DynamoDB 自己拒绝一个授权头缺失或格式有误的请求时,异常是 MissingAuthenticationTokenException——HTTP 400,不可重试,消息是 "Request must contain a valid (registered) AWS Access Key ID."。
为什么会发生
- endpoint URL 错误——在浏览器里或用普通 GET 去打
https://dynamodb.<region>.amazonaws.com/some/path,而不是用正确签名的 SDK 调用打服务根地址。 - 未签名的请求——一个没有 SigV4
Authorization头的裸curl/fetch(SDK 通常会加上它)。 - HTTP 方法错误——DynamoDB 的 API 期望对
/发POST,并带上点名操作的X-Amz-Target头;其他形状不会被识别成已签名的操作。 - 自定义 endpoint 拼错了——指向了一个并不对应 DynamoDB 服务的 URL。
- DynamoDB Local 没有配置访问密钥——即使在本地,SDK 也要求设置访问密钥和区域值(任何值都行;Local 只用它们来给自己的数据库文件命名)。
如何修复
- 用 AWS SDK,而不是裸的 HTTP 调用。让 SDK 构造带正确
X-Amz-Target的已签名POST——别手工拼 URL。 - 指向服务根地址(
https://dynamodb.<region>.amazonaws.com),而不是某个路径,并把客户端的区域设成与之匹配。 - 确认凭证已配置好,这样 SDK 才会真的去签名(环境变量、profile 或角色)。
- 对于 DynamoDB Local,把 endpoint 设成
http://localhost:8000,并配一个假的访问密钥/密钥(只用字母和数字),好让 SDK 正常签名——Local 并不校验它们。
复现方法
发送完全没有 Authorization 标头的格式正确的 DynamoDB 请求:
import requests
requests.post(
'https://dynamodb.us-east-1.amazonaws.com',
headers={
'X-Amz-Target': 'DynamoDB_20120810.ListTables',
'Content-Type': 'application/x-amz-json-1.0',
},
data='{}',
)实际输出:
MissingAuthenticationTokenException: Request is missing Authentication Token
HTTP 400值得注意的是,当你通过 SDK 收到此消息时:这通常意味着请求从未签名,而不是凭证错误。未签名的请求是你从手动 HTTP 调用、剥离标头的代理或需要 IAM 身份验证的 API 网关路由获得的内容 - 因此请查看请求的构建方式而不是密钥。
DynoTable + Local
DynoTable 通过 AWS SDK 对每个 DynamoDB 调用进行签名 — 无需手动构建
Authorization 标头 (Connect an AWS account)。对于
DynamoDB 本地,添加端点为 http://localhost:8000 的配置文件并占位符凭据,以便正常签署请求;本地忽略该键值,但仍然需要它们 (Running DynamoDB Local)。如果你在真实的 AWS 上看到此情况,请确认 Settings → Profiles 指向正确的区域端点并且Test Connection在打开之前成功表。 DynamoDB Expression Builder
一旦端点正确,确认签名的请求有效。
相关错误
- Unable to locate credentials——SDK 完全没有找到任何凭证。
- The security token included in the request is invalid——凭证在,但被拒绝了。
- Could not connect to the endpoint URL——endpoint 格式有误或不可达。
- 学习:Connect to DynamoDB Local & LocalStack
来源
- Troubleshoot Signature Version 4 signing for AWS API requests — IAM User Guide(2026-07-13 验证)
- Error handling with DynamoDB — Amazon DynamoDB Developer Guide(2026-07-13 验证)
- Create a signed AWS API request — IAM User Guide(2026-07-13 验证)
- DynamoDB local usage notes — Amazon DynamoDB Developer Guide(2026-07-13 验证)
根据 us-east-1 中的实时 DynamoDB 服务于 2026 年 7 月 26 日转载 — 上面的输出是逐字记录的。