Obtain JWT Token using Basic Auth

Obtain JWT authentication token using Cookie SSO


POST /services/v2/auth/token.json

Header Authorization=Basic base64(username:password)


{ "jwt": "jwt_value"}


Permissions & Notes:

  • The user being used to make the API request must have the role "Use API" found in the "other roles" permissions granted. Subsequent API access calls made with the JWT token will continue to depend upon the permissions of the user with respect to the particular call being made.

  • We added this endpoint in version 2.18.0

Sample Request

Retrieve an auth token using basic authentication with curl

curl -u "username:password" -H "Accept: application/json" -H "Content-type: application/json" -X POST "https://hostname/services/v2/auth/token.json"

username -The AnswerHub user name

password - The AnswerHub password

hostname - The hostname for the AnswerHub instance

Sample response:

idToken - The authentication token

ExpiresIn - The number of seconds that the token is valid for

-u "unswerhub:test123"
-H "Accept: application/json" 
-H "Content-type: application/json" 
-X POST "https://hostname/services/v2/auth/token.json"

Expected Response

Successful Response:

  • HTTP Status 200 - OK is returned with JWT in payload where valid user is specified in basic auth header.

UnSuccessful Responses:

  • HTTP Status 400 - Bad Request is returned for no basic auth header specified
  • HTTP Status 401 - Bad Request is returned if username or password are invalid in basic auth header
  • HTTP Status 401 - May be error condition on subsequent API calls made for other actions using the token if the user does not have USE_API permission, or user lacks the specific permissions related to the API action.

Community User Interface Result

Actions in the UI will relate to the corresponding API executed with the token.
No UI activity is expected from the Token request itself

Click Try It! to start a request and see the response here!