TestingAPIs is still being built. If something breaks, email support@testingapis.com.

Log in and receive a JWT access token and a refresh token

POSThttps://api.testingapis.com/api/auth/jwt/loginSign in to see this endpoint's URL

Users: admin / admin123 (role admin), user / user123 (role user). Access tokens expire after 15 minutes. Send them as Authorization: Bearer <accessToken>.

Request body

Optional. application/json, text/json, application/*+json, application/xml, text/xml, application/*+xml. Model: JwtAuthControllerLoginRequest. Username and password.

Example body
{"username": "admin", "password": "admin123"}

Responses

200
accessToken, tokenType, expiresIn, refreshToken and user.
400
username or password missing.
401
Wrong username or password.

Example

Request
curl -X POST "https://api.testingapis.com/api/auth/jwt/login" \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "admin123"}' \
  -H "X-TestingApis-Key: YOUR_API_KEY"
Response200 OK
{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI…
  "tokenType": "Bearer",
  "expiresIn": 900,
  "refreshToken": "jrt_812bbc710f53465534cb39e4a0e98ba198616510",
  "user": {"username": "admin", "role": "admin", "name": "Alice Admin}
}

Sign in to see the details

The parameters, request and response examples and the live Try it panel for this endpoint are for signed-in members. Accounts are free and take a few seconds to create.