
# 获取CC-Messaging的Token
#### 接口功能
调用ApplyToKen接口，获取CC-Messaging的Token
#### 请求方法
该接口仅支持POST方法，不支持PUT、GET和DELETE等方法。
#### 请求URL
https://域名/apiaccess/ccmessaging/applyToken
#### 请求消息
- 消息头 x-app-key: [开发前准备](https://support.huaweicloud.com/devg-voip-cec/cec_05_1000.html)中的app_key
  Authorization：'Bearer '+[C1 系统配置类接口鉴权方式](https://support.huaweicloud.com/devg-voip-cec/cec_05_1002.html)中的AccessToken
  Content-Type:application/json; charset=UTF-8
  
- 消息体 该接口的请求消息体举例如下：
  ```
  {    "userId":"xxx",
       "userName":"xxx",
       "channelId":"xxx",
       "locale":"zh",
  }
  ```
  该接口的请求消息体参数说明如[表1]所示。
  
 表1消息体参数说明 
| 参数名       | 数据类型   | 选取原则 | 说明         |
|:---|:---|:---|:---|
| userId    | String | 必选   | 接入该渠道的用户Id |
| userName  | String | 必选   | 接入该渠道的用户名  |
| channelId | String | 必选   | 需要接入的渠道Id  |
| locale    | String | 必选   | 语言种类       |
   
#### 响应消息
该接口的响应消息体举例如下：
```
{    "resultCode":"0",
    "token":"xxx"
}
```
该接口的响应消息体参数说明如[表2]所示。
 表2消息体参数说明 
| 参数名        | 数据类型   | 说明     |
|:---|:---|:---|
| resultCode | String | 请求结果。  |
| token      | String | token。 |
   
#### 异常处理
常见错误返回 （HTTP status 非200返回）
```
{     "errorCode":"0",
     "exceptionInfo":"xxx" 
}
```
​请根据exceptionInfo中返回的描述寻求原因：如出现 403返回，"exceptionInfo": "auth fail! illegal or expired token info. please apply or refresh the access token from the server!"，可能是上一步申请的AccessToken过期导致。
