Token Authentication API

This is the API for getting the Access Token.

Request Url

https://my-api.advance.ai/openapi/auth/ticket/v1/generate-token
POST (application/json)
https://ph-api.advance.ai/openapi/auth/ticket/v1/generate-token
POST (application/json)
https://th-api.advance.ai/openapi/auth/ticket/v1/generate-token
POST (application/json)
https://api.advance.ai/openapi/auth/ticket/v1/generate-token
POST (application/json)

Request Parameters

ParameterDescription
accessKeystring the accessKey
timestampstring 13-digit-long timestamp
signaturestring Combined accessKey, secretKey and timestamp, encrypted by SHA256.
eg.
accessKey: sampleaccesskey
secretKey: samplesecretkey
timestamp: 1665993522952
Combined: sampleaccesskeysamplesecretkey1665993522952
Encrypted based on the combined: 02209bbeaf0d0a3dd587f6a1ba22f84c98d142e3b545e77db7e4906ca56349f5
periodSecondstring optional Validity period defaults to 3600 seconds, minimum 60 seconds, maximum 86400 seconds. Unit is seconds

Note:

  • You can find accessKey, secretKey on the Websaas Platform -> Account -> Account Management
  • The timestamp in the “signature” must be consistent with parameter timestamp
  • Please remember to re-obtain a new valid token to do the authentication for the open APIs when the previous one is expired

Code Sample

curl -X POST \
-H "Content-Type: application/json" \
-d '{"accessKey":"22**70b","signature":"f786441e7b3d95f*****853a5a244f9522","timestamp":1648785145789,"periodSecond":120}' \
"https://api.advance.ai/openapi/auth/ticket/v1/generate-token"

Response Description

ParameterDescription
codeResponse Status Code
messageMessage returned from server
datatoken AccessToken
expiredTime Expiration timestamp
extraExtra response info such as exception message
transactionIdthe request id, the max length is 64
pricingStrategyDeprecated, Always return FREE

Response Code

Status CodeMessage
SUCCESSOK
PARAMETER_ERRORTimestamp error
Parameter should not be empty
Signature error
ACCOUNT_DISABLEDAccount Disabled
CLIENT_ERRORHTTP 400 - Bad Request

Response Examples

SUCCESS

{
    "code":"SUCCESS",
    "message":"OK",
    "data":{
    "token":"eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJoNV9saXZlbmVzcyIsInN1YiI6IntcImN1c3RvbWVySWRcIjo1NTAwMDI4MixcImFjY291bnRJZFwiOjU1MDAwMjg0LFwicmVhbElwXCI6XCI0NS4yNTEuMTA3LjExMVwifSIsImF1ZCI6IldFQiIsImlhdCI6MTY0MjU4MDA3MiwiZXhwIjoxNjQyNTgwMTkyfQ.HmIDcuSW67A59x7bnumjGp0Wdcz-FmoDrnHF1YGui6wVPfulLn4Izonay5LQnySgph1dbyC1E0LtifS-BJo8VA",
    "expiredTime":1642580192430
    },
    "extra":null,
    "transactionId":"6c2c50a3049ce67e",
    "pricingStrategy":"FREE"
}

PARAMETER_ERROR

{
    "code":"PARAMETER_ERROR",
    "message":"Parameter should not be empty",
    "data":null,
    "extra":null,
    "transactionId":"040e769e38f87e3e",
    "pricingStrategy":"FREE"
 }
{
    "code":"PARAMETER_ERROR",
    "message":"Timestamp error",
    "data":null,
    "extra":null,
    "transactionId":"a9c2a6c199ad5db5",
    "pricingStrategy":"FREE"
}
{
    "code":"PARAMETER_ERROR",
    "message":"Signature error",
    "data":null,
    "extra":null,
    "transactionId":"00b05cb9cf6f0fed",
    "pricingStrategy":"FREE"
}

ACCOUNT_DISABLED

{
    "code":"ACCOUNT_DISABLED",
    "message":"Account Disabled",
    "data":null,
    "extra":null,
    "transactionId":"5e00fded1272490e",
    "pricingStrategy":"FREE"
}

CLIENT_ERROR

{
    "code":"CLIENT_ERROR",
    "message":"HTTP 400 - Bad Request",
    "data":null,
    "extra":null,
    "transactionId":"bd5d5653c45d4c6e",
    "pricingStrategy":"FREE"
 }