使用一次性密钥签发测试 JWT
POST
/jwt/sign公开访问curl
每次请求生成新的测试签发密钥,并返回令牌和对应验证材料。非对称签名返回公钥 JWK,HMAC 返回 Base64URL 共享密钥。请求仅接受算法和测试 Payload。 访问类别:匿名 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/jsonalgorithm必填- string · 可选:HS256、HS384、HS512、RS256、ES256、EdDSA、Ed25519
payload必填- object · JSON 对象,编码后上限 10,000 字节。exp、iat 与 nbf 使用 Unix 秒。
响应
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"
]
},
"token": {
"type": "string"
},
"verificationKey": {
"type": "object",
"properties": {
"kind": {
"type": "string",
"enum": [
"jwk",
"secret-base64url"
]
},
"value": {
"type": "string"
}
},
"required": [
"kind",
"value"
]
}
},
"required": [
"header",
"payload",
"times",
"token",
"verificationKey"
]
}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 '{"algorithm":"ES256","payload":{"sub":"example","exp":4102444800}}' https://oit.sh/jwt/signHTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"header": {
"alg": "ES256",
"typ": "JWT"
},
"payload": {
"sub": "example",
"exp": 4102444800
},
"token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJleGFtcGxlIiwiZXhwIjo0MTAyNDQ0ODAwfQ.bD2AdsuNtVm_0nIvRl3wE2XoZ6Lx5azFLYexXkUyudyWdNKcJ3-kSqk8YP7bkMJ4jaP2vf3aE5eKMEJbczQtGA",
"times": {
"exp": "2100-01-01T00:00:00.000Z",
"iat": null,
"nbf": null
},
"verificationKey": {
"kind": "jwk",
"value": "{\"kty\":\"EC\",\"crv\":\"P-256\",\"x\":\"4D528U_kT15KrOOt2t3vp5r-d3Uk476_m19VnTerGds\",\"y\":\"nx3I61fMPim-EFbGu5-TyRwsDzNGyMz0kURJpCs2_GA\"}"
}
}错误示例
curl -sS --json '{}' https://oit.sh/jwt/signHTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"error": {
"code": "INVALID_INPUT",
"message": "参数无效",
"issues": [
{
"location": "body",
"field": "algorithm",
"code": "invalid_value",
"message": "允许值:HS256、HS384、HS512、RS256、ES256、EdDSA、Ed25519"
},
{
"location": "body",
"field": "payload",
"code": "invalid_type",
"message": "需要 record 类型"
}
]
}
}curl 访问示例
curl、wget、HTTPie 默认得到 text/plain。示例展示纯文本输出。
命令与输出
curl -sS --json '{"algorithm":"ES256","payload":{"sub":"example","exp":4102444800}}' 'https://oit.sh/jwt/sign?_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
token: eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJleGFtcGxlIiwiZXhwIjo0MTAyNDQ0ODAwfQ.eCsPa1gzWfxYsDmK8iHcTfgCZGQHnDTPOAOiM7SeROplB-CYKjkuu-BwFOrvuyogsANNi2AxrKSfNCO_5bGviA
times:
exp: 2100-01-01T00:00:00.000Z
iat: null
nbf: null
verificationKey:
kind: jwk
value: {"kty":"EC","crv":"P-256","x":"m6o8CSrH8Yzq8iFARyP76XZZ8SQuhUAg_y0K-iAig24","y":"viIIP-ClrKgP44tkTYVWwtP9WrXWYWfv4rg6o2tPl5w"}
在线调试
curl -X POST 'https://oit.sh/jwt/sign' \
-H 'Content-Type: application/json' \
--data-raw '{"algorithm":"ES256","payload":{"sub":"example","exp":4102444800}}'响应
等待发送请求