使用公钥验证 JWT 签名与声明
POST
/jwt/verify公开访问curl
显式指定算法和 PEM 公钥、JWK 或 JWKS。校验签名及 exp、nbf 声明,可同时检查预期签发者和受众。 访问类别:匿名 API,可携带 Token 使用独立额度
请求参数
_formatquery- 响应格式为 json 或 text;_format=svg 返回 JSON。plain 是 text 的别名。未识别的值继续按 Accept 协商。
- string · 可选:json、text
_colorquery- 控制 text 响应的 ANSI 颜色。0、false、off、no 关闭;省略或其他值保留。
- string · 可选:0、false、off、no
请求体
application/jsontoken必填- string · 最短:1 字符 · 最长:16384 字符
algorithm必填- string · 可选:RS256、ES256、EdDSA、Ed25519
key必填- object
issuer- string · 最短:1 字符 · 最长:1024 字符
audience- string · 最短:1 字符 · 最长:1024 字符
响应
application/json
{
"type": "object",
"properties": {
"header": {
"type": "object",
"additionalProperties": {}
},
"payload": {
"type": "object",
"additionalProperties": {}
},
"times": {
"type": "object",
"properties": {
"exp": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 时间,支持扩展年份",
"example": "1970-01-01T00:00:00.000Z"
},
"iat": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 时间,支持扩展年份",
"example": "1970-01-01T00:00:00.000Z"
},
"nbf": {
"type": [
"string",
"null"
],
"description": "UTC ISO 8601 时间,支持扩展年份",
"example": "1970-01-01T00:00:00.000Z"
}
},
"required": [
"exp",
"iat",
"nbf"
]
},
"verified": {
"type": "boolean",
"enum": [
true
]
}
},
"required": [
"header",
"payload",
"times",
"verified"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}响应示例
成功响应
curl -sS --json '{"token":"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJleGFtcGxlIiwiZXhwIjo0MTAyNDQ0ODAwfQ.kFCRIAKHf6-MmCkBYx2oteHbAkHTbr-b1imUby4AFZvP7Xs_GIWfAwqXcFhV5l4mgQzG9nAoAwOKHVVNONAR4Q","algorithm":"ES256","key":{"kind":"jwk","value":"{\"kty\":\"EC\",\"x\":\"3IGyfUXWWzPjN9xgeZrNbXONUcnzQs2VNDFl1ARNHaI\",\"y\":\"xR98gXqck8ulm62TvnWIIi5uaka57T11JJ6LeK1px_o\",\"crv\":\"P-256\"}"}}' https://oit.sh/jwt/verifyHTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"header": {
"alg": "ES256",
"typ": "JWT"
},
"payload": {
"sub": "example",
"exp": 4102444800
},
"verified": true,
"times": {
"exp": "2100-01-01T00:00:00.000Z",
"iat": null,
"nbf": null
}
}错误示例
curl -sS --json '{}' https://oit.sh/jwt/verifyHTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"error": {
"code": "INVALID_INPUT",
"message": "参数无效",
"issues": [
{
"location": "body",
"field": "token",
"code": "invalid_type",
"message": "需要 字符串 类型"
},
{
"location": "body",
"field": "algorithm",
"code": "invalid_value",
"message": "允许值:RS256、ES256、EdDSA、Ed25519"
},
{
"location": "body",
"field": "key",
"code": "invalid_type",
"message": "需要 对象 类型"
}
]
}
}curl 访问示例
curl、wget、HTTPie 默认得到 text/plain。示例展示纯文本输出。
命令与输出
curl -sS --json '{"token":"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJleGFtcGxlIiwiZXhwIjo0MTAyNDQ0ODAwfQ.kFCRIAKHf6-MmCkBYx2oteHbAkHTbr-b1imUby4AFZvP7Xs_GIWfAwqXcFhV5l4mgQzG9nAoAwOKHVVNONAR4Q","algorithm":"ES256","key":{"kind":"jwk","value":"{\"kty\":\"EC\",\"x\":\"3IGyfUXWWzPjN9xgeZrNbXONUcnzQs2VNDFl1ARNHaI\",\"y\":\"xR98gXqck8ulm62TvnWIIi5uaka57T11JJ6LeK1px_o\",\"crv\":\"P-256\"}"}}' 'https://oit.sh/jwt/verify?_color=0&_format=text'HTTP 200 content-type: text/plain; charset=utf-8 content-encoding: gzip cache-control: no-store header: alg: ES256 typ: JWT payload: sub: example exp: 4102444800 verified: true times: exp: 2100-01-01T00:00:00.000Z iat: null nbf: null
在线调试
curl -X POST 'https://oit.sh/jwt/verify' \
-H 'Content-Type: application/json' \
--data-raw '{"token":"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJleGFtcGxlIiwiZXhwIjo0MTAyNDQ0ODAwfQ.kFCRIAKHf6-MmCkBYx2oteHbAkHTbr-b1imUby4AFZvP7Xs_GIWfAwqXcFhV5l4mgQzG9nAoAwOKHVVNONAR4Q","algorithm":"ES256","key":{"kind":"jwk","value":"{\"kty\":\"EC\",\"x\":\"3IGyfUXWWzPjN9xgeZrNbXONUcnzQs2VNDFl1ARNHaI\",\"y\":\"xR98gXqck8ulm62TvnWIIi5uaka57T11JJ6LeK1px_o\",\"crv\":\"P-256\"}"}}'响应
等待发送请求