Updated on 2024-03-05 GMT+08:00

Obtaining the Token of CC-Messaging

Interface Function

The ApplyToKen interface is invoked to obtain the token of CC-Messaging.

Request Method

This interface supports only the POST method, and does not support the PUT, GET, or DELETE method.

Request URL

https://API Fabric domain name/apigovernance/api/oauth/tokenByAkSk

Request Message

  • Message header

    x-app-key: app_key in Preparations Before Development

    Authorization: Bearer + AccessToken obtained in Generating a Token Using the API Fabric

    Content-Type:application/json; charset=UTF-8

  • Message body

    The following provides an example of the request message body of this interface:

    {    "userId":"xxx",
         "userName":"xxx",
         "channelId":"xxx",
         "locale":"zh",
    }

    Table 1 describes the parameters in the request message body of this interface.

Table 1 Parameters in the message body

Parameter

Type

Mandatory

Description

userId

String

Yes

ID of the user who accesses the channel.

userName

String

Yes

User name for accessing the channel.

channelId

String

Yes

ID of the channel to be accessed.

locale

String

Yes

Language type.

Response Message

The following provides an example of the response message body of this interface:

{    "resultCode":"0",
    "token":"xxx"
}

Table 2 describes the parameters in the response message body of this interface.

Table 2 Parameters in the message body

Parameter

Type

Description

resultCode

String

Request result.

token

String

A token.

Troubleshooting

The following is the common returned error information (returned when http status is not 200):

{     "errorCode":"0",
     "exceptionInfo":"xxx" 
}

Find the cause based on the description in exceptionInfo. For example, if error code 403 and the following exceptionInfo are returned, the token applied in the previous section has expired:

"auth fail! please apply or refresh the access token from the server!"