Your Guide to the Token Authentication API

What is the purpose of the Token Authentication API?

The Token Authentication API generates secure access tokens for authenticating requests to other ADVANCE APIs.

How do I generate an access token?

  1. Obtain your accessKey and secretKey from the Websaas Platform.

  2. Create a SHA256-encrypted signature combining your accessKey, secretKey, and a 13-digit timestamp.

  3. Make a POST request to https://api.advance.ai/openapi/auth/ticket/v1/generate-token with the following parameters:

    • accessKey: Your access key

    • timestamp: Current timestamp (within 300 seconds of server time)

    • signature: The SHA256-encrypted string

    • periodSecond (optional): Validity period of the token (default: 3600 seconds)

What does a successful response look like?

{
    "code": "SUCCESS",
    "message": "OK",
    "data": {
        "token": "eyJhbGciOiJIUzUxMiJ9...",
        "expiredTime": 1642580192430
    },
    "transactionId": "6c2c50a3049ce67e",
    "pricingStrategy": "FREE"
}

What errors might occur during token generation?

  • PARAMETER_ERROR: Ensure parameters like accessKey, timestamp, or signature are correct.

  • ACCOUNT_DISABLED: Contact support if your account is disabled.

  • CLIENT_ERROR: Check the request format and parameters.

What are the key best practices for token management?

  • Always use the latest token for API requests.

  • Re-generate tokens before the current token expires.

  • Securely store your accessKey and secretKey to avoid unauthorized access.

Was this article helpful?
24 out of 24 found this helpful

Comments

0 comments

Please sign in to leave a comment.