5.1.1 Obtain a JWT

Title

Obtain a JWT (authenticate user)

URL Path

/api/user/authenticate

Method

POST

Summary

Obtain a token and a refresh token by authenticating using a username and password.

Sample HTTP body

{
  "userName": "Admin",
  "password": "AdminPassword"
}

Description of request

userName

The name of the user to be authenticated

string value

password

The password of the user to be authenticated

string value

Request Errors

400 Bad Request

Invalid HTTP request

500 Internal Server Error

Server is temporarily unavailable

Response

Example of a successful request:

{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOiI1ZGVlOWY0NjgwM2NhNjAwMDdmNDZiODgiLCJ1bmlxdWVfbmFtZSI6ImFkbWluIiwiZW1haWwiOiJhZG1pbkBhZG1pbiIsIm5iZiI6MDU3NjA5MDA3MSwiZXhwIjoxNTc2MDkzNjcxLCJpYXQiOjE1NzYwOTAwNzF9.u7i4ssMIJePETl3cZ8hnH4B9YmBs_q5Ll9mMlRxQYRg",
"email": "admin@admin",
"fullName": "Admin",
"accessTokenExpiryTime": "2020-07-09T23:12:29.3560169Z",
"refreshToken": "2XYnghwh3g16QXbU0+8I6+bZvmfGzrzamlFgkokYtDY=",
"refreshTokenExpiryTime": "2020-07-09T23:12:29.3560169Z",
"responseKey": "SUCCESS",
"responseMessage": "Successful request",
"role": 2,
"userName": "admin"
}

Please note that the accessToken is only valid for an hour so it should be periodically refreshed.

Description of response

fullName

User’s full name

The full name of the user

email

User’s email address

The email address of the user

accessToken

JWT token

The JWT Bearer token that represents the authority of the user

accessTokenExpiryTime

Access token’s expiration time (UTC)

The expiration time of the given access token

refreshToken

Refresh token

A longer-lived token used to retrieve a new JWT token when the old one expires

refreshTokenExpiryTime

Refresh token’s expiration time (UTC)

The expiration time of the given refresh token

responseKey

Response message key

A message key that can be used for internalization

responseMessage

Response message

A message describing the result of the request

role

User’s role

a numeric value representing the user’s role

userName

User’s username

The username of the user