Obtain JWT Token using Basic Auth

Obtain JWT authentication token using Cookie SSO

/services/v2/auth/token.json

Request
POST /services/v2/auth/token.json

Header Authorization=Basic base64(username:password)

Response

{ "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":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJqZWZmdGVzdDAxIiwidXNlciI6Ik5UWXdOVEkxTVdRdE1HSmtaQzAwWVdJd0xUaG1Zak10WXpkbE5qSTVOV1l5WW1JdyIsImlhdCI6MTYxMzE1OTc2OSwiaXNzIjoiaHR0cHM6Ly9haC10ZXN0LW10LXRlc3QxLmNsb3VkLmFuc3dlcmh1Yi5jb20iLCJhdWQiOiJodHRwczovL2FoLXRlc3QtbXQtdGVzdDEuY2xvdWQuYW5zd2VyaHViLmNvbSIsImp0aSI6IjVhZDhlNTMwLWM1YmUtNDg5MC1iMjVmLTUxNjY0MmExM2JlYSIsImV4cCI6MTYxMzE4MTM2OX0.ZJtW8gzVeCp5ptmgzJw7z-KRDUSpEYll3sraTYngFOhrwdBRchaZZo_JZJMLuhwejnR5YJYR17SvKlj5vBP_Hg",
"expiresIn":21600
}

idToken - The authentication token

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

curl 
-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

Language
Authorization
Basic
base64
:
Click Try It! to start a request and see the response here!