Show / Hide Table of Contents

Token Request with API credentials

The purpose of this call is to authenticate our clients and return an Access Token which will be used for further calls to the API. The token is now valid by default for 24 hours since it was first issued. The expiresAt property is the one that will provide accurate information about when the token will expire. After that, in order to make API calls, the user will have to ask for a new token. This call should be used by integrators to allow their apps to use Language Weaver. This allows the integrations to make calls without a user context. This Access Token will be added to the Authorization header of all API requests in the form "Authorization": "Bearer asd0eXAi..."

Linux

curl -XPOST -H "Content-type: application/json" -d '{
    "clientId": "F0ZUe28HFE8eaMLRLGJrIK0M6WGI92Nu",
    "clientSecret": "HFE8etNdtUP1liTrIKCtvlbGZ8Bv6Sxb-TAO_etNdHEcbWGu0KPGkVIu4QjiNEBt"
}' 'https://api.languageweaver.com/v4/token'
Windows

curl -XPOST -H "Content-type: application/json" -d ^
"{^
 \"clientId\":\"F0ZUe28HFE8eaMLRLGJrIK0M6WGI92Nu\",^
 \"clientSecret\":\"HFE8etNdtUP1liTrIKCtvlbGZ8Bv6Sxb-TAO_etNdHEcbWGu0KPGkVIu4QjiNEBt\"^
}" https://api.languageweaver.com/v4/token

HTTP Request
POST /v4/token

Request Parameters

Request JSON:

{
    "clientId": "F0ZUe28HFE8eaMLRLGJrIK0M6WGI92Nu",
    "clientSecret": "HFE8etNdtUP1liTrIKCtvlbGZ8Bv6Sxb-TAO_etNdHEcbWGu0KPGkVIu4QjiNEBt"
}

Format
JSON

Name Type Mandatory Default value Description
clientId string yes The clientId associated with the account
clientSecret string yes The client secret for this clientId

Response JSON:

{
"accessToken": "asd0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsI",
"validityInSeconds": 86400,
"tokenType": "Bearer",
"expiresAt": 1538505336000
}

Response

Format
JSON

Name Type Description
accessToken string Valid access token in JSON Web Token (JWT) format
validityInSeconds integer The time the token is valid
tokenType string Bearer
expiresAt long A timestamp (epoch) representing the expiration time of the token

Error JSON:

{
   "errors":[
      {
         "code":54,
         "description":"Unable to generate the access token. Verify your credentials and try again."
      }
   ]
}

Error Response

Format
JSON

Name Type Description
errors list A list with the errors that occurred
code integer The code of the error
description string The description of the error

Returned HTTP Codes:

Http Code Description
200 When the token is successfully generated
400 When the input data is not valid
401 When the authentication process failed or the access token is not valid
500 Application internal error

Token Request with user credentials

The purpose of this call is to authenticate our clients and return an Access Token which will be used for further calls to the API. The token is now valid by default for 24 hrs. After that, in order to make API calls, the user will have to ask for a new token. This call should be used by integrators who need to make calls with the user's credentials. This Access Token will be added to the Authorization header of all API requests in the form "Authorization": "Bearer asd0eXAi..."

Note

Authentication using user credentials is not allowed when Single Sign-On (SSO) is enabled.

Linux

curl -XPOST -H "Content-type: application/json" -d '{
    "username": "username@domain.com",
    "password": "userpassword"
}' 'https://api.languageweaver.com/v4/token/user'
Windows

curl -XPOST -H "Content-type: application/json" -d ^
"{^
 \"username\":\"username@domain.com\",^
 \"password\":\"userpassword\"^
}" https://api.languageweaver.com/v4/token/user

HTTP Request
POST /v4/token/user

Request Parameters

Request JSON:

{
    "username": "username@domain.com",
    "password": "userpassword"
}

Format
JSON

Name Type Mandatory Default value Description
username string yes User's email address
password string yes User's password

Response JSON:

{
"accessToken": "asd0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsI",
"validityInSeconds": 86400,
"tokenType": "Bearer",
"expiresAt": 1538505336000
}

Response

Format
JSON

Name Type Description
accessToken string Valid access token in JSON Web Token (JWT) format
validityInSeconds integer The time the token is valid
tokenType string Bearer
expiresAt long A timestamp (epoch) representing the expiration time of the token

Error JSON:

{
   "errors":[
      {
         "code":54,
         "description":"Unable to generate the access token. Verify your credentials and try again."
      }
   ]
}

Error Response

Format
JSON

Name Type Description
errors list A list with the errors that occurred
code integer The code of the error
description string The description of the error

Returned HTTP Codes:

Http Code Description
200 When the token is successfully generated
400 When the input data is not valid
401 When the authentication process failed or the access token is not valid
500 Application internal error
In This Page
Back to top