# 获取应用级凭证

> phone | 2in1 | tablet

此接口用于获取访问token，该token相当于一个访问许可，部分接口请求时华为支付服务器会对其进行校验。

## 接口原型

* **承载协议：** HTTPS POST

* **接口方向：** 开发者服务器 -> 华为云服务器

* **接口URL：** https://oauth-login.cloud.huawei.com/oauth2/v3/token

* **数据格式：**

  请求消息：Content-Type: application/x-www-form-urlencoded

  响应消息：Content-Type: application/json;charset=UTF-8

## 请求参数

**Request Header**

|参数|是否必选|参数类型|描述|
|:-----------|:---|:-----|:------------------------------------|
|Content-Type|是|String|取值为：application/x-www-form-urlencoded|

**Request Body**

|参数|是否必选|参数类型|描述|
|:------------|:---|:-----|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|grant_type|是|String|填写为"client_credentials"，表示为客户端模式。|
|client_id|是|String|应用的OAuth 2.0客户端ID（在[AppGallery Connect](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html)网站点击"我的项目"，在项目列表中找到项目，在"项目设置 > 常规"页面的"应用"区域获取"OAuth 2.0客户端ID（凭据）：Client ID"的值）|
|client_secret|是|String|应用的OAuth 2.0客户端ID分配的密钥（在[AppGallery Connect](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html)网站点击"我的项目"，在项目列表中找到项目，在"项目设置 > 常规"页面的"应用"区域获取"OAuth 2.0客户端ID（凭据）：Client Secret"的值）|

## 请求示例

```json
POST /oauth2/v3/token?grant_type=client_credentials&client_id=<客户端ID>&client_secret=<客户端密钥> HTTP/1.1
Content-Type: application/x-www-form-urlencoded
```

## 响应参数

**Response Header**

|参数|是否必选|参数类型|描述|
|:-----------|:---|:-----|:---------------------------------|
|Content-Type|是|String|取值为：application/json;charset=UTF-8|

**Response Body**

|参数|是否必选|参数类型|描述|
|:-----------|:---|:-----|:--------------------------------|
|token_type|是|String|固定字符串"Bearer"。|
|access_token|是|String|Access Token。应用凭据。|
|expires_in|否|Long|Access Token的过期时间，以秒为单位。默认60分钟过期。|

## 响应示例

```json
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
  "access_token": "<返回的Access Token>",
  "expires_in": 3600,
  "token_type": "Bearer"
}
```

