JWT 认证
JWT:登录获取签名的 JWT,调用受 [Authorize] 和角色检查保护的端点,轮换刷新令牌,并获取一个已过期的令牌用于反向测试。
你的账号已解锁这些端点。在每个端点的页面上用 Try it 发送请求。
- GET
https://api.testingapis.com/api/auth/jwt/adminAllow only JWTs with the admin roleAllow only JWTs with the admin role. - GET
https://api.testingapis.com/api/auth/jwt/expiredReturn a correctly signed JWT that expired an hour agoReturn a correctly signed JWT that expired an hour ago. - POST
https://api.testingapis.com/api/auth/jwt/loginLog in and receive a JWT access token and a refresh tokenLog in and receive a JWT access token and a refresh token. - GET
https://api.testingapis.com/api/auth/jwt/meReturn the claims of the current JWTReturn the claims of the current JWT. - POST
https://api.testingapis.com/api/auth/jwt/refreshExchange a refresh token for new tokensExchange a refresh token for new tokens.
请求示例
Allow only JWTs with the admin role. 完整参考和 Send 按钮(英文).
cURL
curl -X GET "https://api.testingapis.com/api/auth/jwt/admin" \
-H "Authorization: Bearer {{adminJwt}}"响应 · 200 OK
{"message": "Welcome, admin. You passed the role check.", "username": "admin"}