Help Center/ Cognitive Engagement Center/ API Reference/ Web Client Access Interface Reference/ Performing Third-Party Request Authentication (applyToken)
Updated on 2023-09-27 GMT+08:00

Performing Third-Party Request Authentication (applyToken)

Scenario

This interface is invoked to generate a client access token for a third-party request.

Method

POST

URI

https://Domain name/apiaccess/ccmessaging/applyToken (For example, the domain name is service.besclouds.com.)

Request Description

Table 1 Request header parameters

No.

Parameter

Type

Mandatory or Not

Description

1

x-app-key

String

Yes

App key, which is the user ID and is configured on the API Fabric

2

Authorization

String

Yes

Authentication field. The format is Bearer {Value of AccessToken returned by the tokenByAkSk interface}. (A space is required after Bearer.)

Table 2 Request body parameter

No.

Parameter

Type

Mandatory or Not

Description

1

reqBody

applyTokenReqBody

Yes

Request body

Table 3 applyTokenReqBody parameters

No.

Parameter

Type

Mandatory or Not

Description

1.1

userId

String

Yes

User ID

The value is defined by the enterprise and is a string of 1 to 32 characters.

1.2

userName

String

Yes

Username

The value is defined by the enterprise. This parameter is used for name display.

1.3

channelId

String

Yes

Channel ID

The value is the same as that of Configuration ID of the channel configured on the Service Channel Configuration > Channel Configuration page in the AICC.

1.4

locale

String

Yes

Language information

The value does not contain the country code. For example, zh indicates Chinese, and en indicates English. For details, see ISO 639 language codes.

Response Description

  • Status code: 200
    Table 4 applyTokenRspBody parameters

    No.

    Parameter

    Type

    Mandatory or Not

    Description

    1.1

    token

    String

    Yes

    Generated token. When another request is initiated later, the value of this parameter must be assigned to ccmessaging-token in the header.

    Notes:

    • The token is valid within 1 hour. If the system returns error code 401 (the authentication fails), you need to use the applyToken interface to generate a token again.
    • If the token expires during a session, the AICC automatically returns a new token for the current request. The enterprise needs to update the value of ccmessaging-token in the header.

    1.2

    resultCode

    String

    Yes

    Result code

    • 0: success
    • 1: failure

    1.3

    resultDesc

    String

    No

    Result description

    Currently, no value is returned.

  • Status code: 400

    Incorrect request. Check the request path and parameters.

  • Status code: 401

    Unauthorized operation. 1. Check whether you have purchased related services. 2. Contact customer service to check the status of your account.

  • Status code: 404

    The requested content is not found. Check the request path.

  • Status code: 500

    Business failure. Check the values of parameters in the request.

Error Codes

None

Example

  • Scenario: example message

    Request parameters:

    {
    	"userId": "XXXXXXXXX",
    	"userName": "XXXXXXXX",
    	"channelId": "XXXXXXXXXXXX",
    	"locale": "en"
    }

    Response parameters:

    {
        "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    }