授權認證API
客戶端模式-獲取訪問令牌
接口地址
POST /api/v1.0/invoke/open-ability/method/oauth2/token
請求參數
| 參數名 | 類型 | 位置 | 必填 | 說明 |
|---|---|---|---|---|
| Content-Type | String | Header | 是 | 內容類型,值爲application/x-www-form-urlencoded |
| Accept | String | Header | 是 | 接受類型,值爲application/json |
| grant_type | String | Body | 是 | 授權類型,值爲client_credentials |
| client_id | String | Body | 是 | 客戶端ID |
| client_secret | String | Body | 是 | 客戶端密鑰 |
| scope | String | Body | 是 | 授權範圍,值爲general |
| expires_in | Integer | Body | 否 | 令牌過期時間,單位:秒 |
返回參數
| 參數名 | 類型 | 位置 | 說明 |
|---|---|---|---|
| Content-Type | String | Header | 內容類型,值爲application/json |
| success | Boolean | Body | 判斷請求是否成功 true:成功 false:失敗 |
| timestamp | Integer | Body | 時間戳 |
| result | Object<result> | Body | 返回結果 |
result說明
| 參數名 | 類型 | 位置 | 說明 |
|---|---|---|---|
| access_token | String | Body | 訪問令牌 |
| refresh_token | String | Body | 刷新令牌 |
| token_type | String | Body | 令牌類型,值爲bearer |
| expires_in | Integer | Body | 令牌過期時間,單位:秒 |
請求示例
POST /api/v1.0/invoke/open-ability/method/oauth2/token
Content-Type: application/x-www-form-urlencoded
Accept: application/json
grant_type=client_credentials&
client_id=caa0b4dffd57202a157bf46664f93c192&
client_secret=s75b058bfd9e4e0659d75b67a03334745&
scope=general
成功返回示例
狀態碼:200
Content-Type: application/json
{
"success": true,
"timestamp": 1540869200562,
"result": {
"access_token": "a9be2f2a080979547f430ffc3e81ba47d",
"refresh_token": "r91b9ba8bc024e23617f63f908dc15951",
"token_type": "bearer",
"expires_in": 3600
}
}
失敗返回示例
見 接口失敗返回
刷新訪問令牌
接口地址
POST /api/v1.0/invoke/open-ability/method/oauth2/token
請求參數
| 參數名 | 類型 | 位置 | 必填 | 說明 |
|---|---|---|---|---|
| Content-Type | String | Header | 是 | 內容類型,值爲application/x-www-form-urlencoded |
| Accept | String | Header | 是 | 接受類型,值爲application/json |
| grant_type | String | Body | 是 | 授權類型,值爲refresh_token |
| client_id | String | Body | 是 | 客戶端ID |
| client_secret | String | Body | 是 | 客戶端密鑰 |
| refresh_token | String | Body | 是 | 刷新令牌 |
| expires_in | Integer | Body | 否 | 令牌過期時間,單位:秒 |
返回參數
| 參數名 | 類型 | 位置 | 說明 |
|---|---|---|---|
| Content-Type | String | Header | 內容類型,值爲application/json |
| success | Boolean | Body | 判斷請求是否成功 true:成功 false:失敗 |
| timestamp | Integer | Body | 時間戳 |
| result | Object<result> | Body | 返回結果 |
result說明
| 參數名 | 類型 | 位置 | 說明 |
|---|---|---|---|
| access_token | String | Body | 訪問令牌 |
| refresh_token | String | Body | 刷新令牌 |
| token_type | String | Body | 令牌類型,值爲bearer |
| expires_in | Integer | Body | 令牌過期時間,單位:秒 |
請求示例
POST /api/v1.0/invoke/open-ability/method/oauth2/token
Content-Type: application/x-www-form-urlencoded
Accept: application/json
grant_type=refresh_token&
client_id=caa0b4dffd57202a157bf46664f93c192&
client_secret=s75b058bfd9e4e0659d75b67a03334745&
refresh_token=r91b9ba8bc024e23617f63f908dc15950
成功返回示例
狀態碼:200
Content-Type: application/json
{
"success": true,
"timestamp": 1540869200562,
"result": {
"access_token": "ad5db2a3d3ab09e5890c4ffba9eaf3c53",
"refresh_token": "r91b9ba8bc024e23617f63f908dc15952",
"token_type": "bearer",
"expires_in": 3600
}
}
失敗返回示例
見 接口失敗返回