Retrieval of a bearer token

When you want to perform any operation on a schema, you must have access to the project in which the schema exists. To gain access you require a bearer token. You can retrieve the bearer token from any external application by using the POST method.

Prerequisites

You must have the following information before you retrieve the project details:

REST API request

To retrieve the information about the bearer token, you must use the request with the following attributes:

Request attributes Request parameters
HTTP method POST
Endpoint https://{OneTest_Server}/onetest-data/rest/v1/otd/login
Authorization

refresh_token: XXXXX

project_id: 1150

Request body Null

Response code

You can view the following response after you run the request:
HTTP response code Response example
200
{ 
  "_id":"5f2aa6689021c4009d6c8d7a", 
  "href":"http://{my-ots}-hip-server:8080/tx-server/rest/v1/tx/sessions/5f2aa6689021c4009d6c8d7a", 
  "tags":[], 
  "token":"XXXXX", 
  "user_id":"5f2aa31a9021c4009d6c8d72", 
  "user_name":"otduser", 
  "user_email":"otduser@gmail.com", 
  "account_id":"5f2a96cf9021c4006ab0e6d6", 
  "account_name":"Default", 
  "created_on":"2020-08-05 12:30:32", 
  "expires_on":"2020-08-12 12:30:32", 
  "roles": 
    { 
    "account_roles":["administrator", "designer"] 
    } 
}

Error codes

The following table lists the error codes that can generate on the failure of the request:
HTTP error codes Response examples
401(Invalid Refresh token/Invalid Project Id)
{ 
    "timestamp": "2020-08-21T05:25:02.867Z", 
    "code": 401, 
    "messages": ["IO Exception occurred while retrieving user from OTS Server."] 
} 
404(Null Project Id)
{ 
   "timestamp": "2020-09-04T06:52:08.213Z", 
    "code": 404, 
    "messages": ["Project Id cannot be null."] 
} 

Example of the cURL command

You can also use the following cURL command to retrieve the details of a bearer token:

curl -X POST 'https://otd-fvt1.nonprod.hclpnp.com/onetest-data/rest/v1/otd/login' \ 
--header 'refresh_token: XXXX' \ 
--header 'projectid: 3400'