V2 Get Token REST Service for OAuth Authentication

GET https://<hostname>/ws/rest/service/v2/auth/token

Purpose

Use this rest service with your credentials to fetch a JWT token to access V2 REST services. The token is valid for date/time available in the response. The token expiration is set to 3600 seconds by default.

Sample Request

Send an API request for a token with the end point URL included in the following curl command.

curl --location --request GET 'http://<HOST_NAME/ws/rest/service/v2/auth/token' \

--header 'Authorization: Bearer XXXXXXX'

Note:

If the endpoint URL has a project number that contains special characters such as / \ : * ? " < > or |, you must change those special characters to URL escape characters. For example, a project number with a special number sign (hash) such as 2020#7 must be changed to 2020%7. You can use a browser to access the list of URL escape characters.

Optional Request Parameter

Use the following parameter to modify the token expiration in the API request:

Request Parameter Data Type Description
expiry string Enter the optional token expiration duration in seconds. For example, expiry=300.

Sample Success Response

{

"data": {

"access_token": "eyJ4NXQjUzI1NiI6IjN2dFl1OU04ejFJSWlieDI2c2k1b2J1ekZ4RlBlRFpTcmhjX01kcHpjcE0iLCJ4NXQiOiItZlVTYTJVeGNzRGxJUzBxbHRrT3c5cEtyNlUiLCJraWQiOiJTSUdOSU5HX0tFWSIsImFsZyI6IlJTMjU2In0.eyJjbGllbnRfb2NpZCI6Im9jaWQxLmRvbWFpbmFwcC5vYzEuaWFkLmFtYWFhYWFhYXF0cDViYWE1Z3Rwd25zbW5nbjY1eGdmcTIyZ3hsamFpeHpidWp3ZmVpNTY0Zmp5YjduYSIsInVzZXJfdHoiOiJBbWVyaWNhXC9DaGljYWdvIiwic3ViIjoiJCRtb2hhbmludCIsInVzZXJfbG9jYWxlIjoiZW4iLCJzaWRsZSI6NDgwLCJ1c2VyLnRlbmFudC5uYW1lIjoiaWRjcy1lOWEyZTBiMWU5MmU0MjQyYWQxM2Y4YWQ2OWJkNzk3ZiIsImlzcyI6Imh0dHBzOlwvXC9pZGVudGl0eS5vcmFjbGVjbG91ZC5jb21cLyIsImRvbWFpbl9ob21lIjoidXMtYXNoYnVybi0xIiwiY2Ffb2NpZCI6Im9jaWQxLnRlbmFuY3kub2MxLi5hY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tDs7a3U-__7wlCvWB-wTFyJtHuZUTNGmx-Ihx3QARNJgIVih5G9XLXrZfZg",

"expires_in": 3600,

"token_type": "Bearer",

"auth_type": "oAuth"

},

"message": [],

"status": 200

}

Supported Response Parameters for OAuth Authentication

The following parameters display with values in the response output:

Response Parameter Data Type Description
access_token string Displays the bearer token.
expires_in string Displays the expiry duration in seconds. By default, 3600 seconds.
token_type string Displays the Bearer token type.
auth_type string Displays the authentication type used by the integration user. Choices include: Basic, and OAuth.
message string Displays the error message.
status string Displays the http status code.

Supported HTTP Status Codes

The following HTTP status codes are supported for this rest service:

HTTP Status Code Status Message Error Message
200 Success not applicable.
400 Bad Request Invalid expiry.
401 Unauthorized

Empty or Invalid Authorization Header.

Invalid Authorization Header

500 Internal Server Error Please contact Administrator with Diagnostic code.