Autentikasi JWT
JWT: login untuk mendapatkan JWT bertanda tangan, panggil endpoint yang dilindungi [Authorize] dan pemeriksaan role, rotasi refresh token, dan ambil token kedaluwarsa untuk pengujian negatif.
- GET
https://api.testingapis.com/api/auth/jwt/adminAllow only JWTs with the admin role. - GET
https://api.testingapis.com/api/auth/jwt/expiredReturn 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 token. - GET
https://api.testingapis.com/api/auth/jwt/meReturn the claims of the current JWT. - POST
https://api.testingapis.com/api/auth/jwt/refreshExchange a refresh token for new tokens.
Contoh request
Allow only JWTs with the admin role. Referensi lengkap dan tombol Send (dalam bahasa Inggris).
cURL
curl -X GET "https://api.testingapis.com/api/auth/jwt/admin" \
-H "Authorization: Bearer {{adminJwt}}"Response · 200 OK
{"message": "Welcome, admin. You passed the role check.", "username": "admin"}