Get Access Token¶
Get the access token using the access key and secret key of your application.
An access token is compatible with an access key. If the access token for your application is already generated, when you call the Get Access Token API again, the same access token will be returned if the access token does not expire.
Prerequisites¶
Register an application on EnOS Console to get the access key and secret key of the application, which are required as the values of the appKey
and appSecret
request parameters of the Get Access Token API.
Request Format¶
POST https://{apigw-address}/apim-token-service/v2.0/token/get
Request Parameters (Body)¶
Name |
Required or Not |
Data Type |
Description |
---|---|---|---|
appKey |
True |
String |
The access key of the application |
encryption |
True |
String |
Encrypted ciphertext. See Encryption Generation Rule >> |
timestamp |
True |
Long |
Time stamp of the current system time (UNIX time, accurate to milliseconds), e.g. 1572574909697 |
Encryption Generation Rule¶
Concatenate the values of
appKey
,timestamp
, andappSecret
to generate a string for encryption.Encode the concatenated string in UTF-8 format and make a digest by SHA256 algorithm.
Convert the digest to hexadecimal format to generate the encrypted ciphertext. See the following pseudo code:
sha256(appKey+timestamp+appSecret).toLowerCase();
Response Parameters¶
Name |
Data Type |
Descritpion |
---|---|---|
status |
Integer |
API request status code, with 0 indicating successful request |
msg |
String |
Explanation of the status codes |
business |
String |
Business parameter, with the value of apim-token-service |
data |
Data Struct |
Generated access token and its expiring time |
Data Struct¶
Name |
Data Type |
Description |
---|---|---|
accessToken |
String |
Value of the generated access token |
expire |
Integer |
Expiring time of the access token in seconds, with an initial value of 7,200 (i.e. 2 hours). |
Sample¶
Request Sample¶
POST
https://{apigw-address}/apim-token-service/v2.0/token/get
{
"appKey": "5acb82e7-a11e-4300-9164-c8b20b638e8b",
"encryption": "87c6885cec7525e2f219f86a82b280cc8c2d6ff4040a4b5f8acf9aeeda37aba8",
"timestamp": 1572574909697
}
Return Sample¶
{
"stauts": 0,
"msg": "SUCCESS",
"business": "apim-token-service",
"data": {
"accessToken": "Generated_Access_Token",
"expire": 7200
}
}