Autenticación JWT
JWT: inicia sesión para obtener un JWT firmado, llama a endpoints protegidos con [Authorize] y una comprobación de rol, rota refresh tokens y obtén un token caducado para pruebas negativas.
Tu cuenta desbloquea estos endpoints. Usa Try it en la página de cada endpoint para enviar peticiones.
Estos endpoints necesitan una cuenta gratuita. Crea una o inicia sesión para ver sus detalles y probarlos aquí.
- 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.
Petición de ejemplo
Allow only JWTs with the admin role. Referencia completa y botón Send (en inglés).
cURL
curl -X GET "https://api.testingapis.com/api/auth/jwt/admin" \
-H "Authorization: Bearer {{adminJwt}}"Respuesta · 200 OK
{"message": "Welcome, admin. You passed the role check.", "username": "admin"}Inicia sesión para ver los detalles
Los parámetros, los ejemplos de petición y respuesta y el panel Try it en vivo de estos endpoints son para miembros con sesión iniciada. Las cuentas son gratuitas y se crean en unos segundos.