跳至主要内容
版本:V4.0

授權認證API


授權碼模式-獲取授權碼

接口地址

GET /api/v1.0/invoke/open-ability/method/oauth2/auth

請求參數

參數名類型位置必填說明
scopeStringQuery授權範圍,值爲user
stateStringQuery客戶端狀態
redirect_uriStringQuery重定向地址
response_typeStringQuery應答類型,值爲code
client_idStringQuery客戶端ID

返回參數

參數名類型位置說明
stateStringQuery客戶端狀態,與入參一致
codeStringQuery授權碼

請求示例

GET /api/v1.0/invoke/open-ability/method/oauth2/auth?scope=user&state=1&response_type=code&client_id=caa0b4dffd57202a157bf46664f93c192&redirect_uri=https://demo.akubela.com

成功返回示例

https://demo.akubela.com?state=1&code=cb66a21f7d9fe1a141676a563c5a7eacf

失敗返回示例



授權碼模式-獲取訪問令牌

接口地址

POST /api/v1.0/invoke/open-ability/method/oauth2/token

請求參數

參數名類型位置必填說明
Content-TypeStringHeader內容類型,值爲application/x-www-form-urlencoded
AcceptStringHeader接受類型,值爲application/json
grant_typeStringBody授權類型,值爲authorization_code
codeStringBody授權碼
client_idStringBody客戶端ID
client_secretStringBody客戶端密鑰
redirect_uriStringBody重定向地址
expires_inIntegerBody令牌過期時間,單位:秒

返回參數

參數名類型位置說明
Content-TypeStringHeader內容類型,值爲application/json
successBooleanBody判斷請求是否成功
true:成功
false:失敗
timestampIntegerBody時間戳
resultObject<result>Body返回結果

result說明

參數名類型位置說明
access_tokenStringBody訪問令牌
refresh_tokenStringBody刷新令牌
token_typeStringBody令牌類型,值爲bearer
expires_inIntegerBody令牌過期時間,單位:秒

請求示例

POST /api/v1.0/invoke/open-ability/method/oauth2/token

Content-Type: application/x-www-form-urlencoded

Accept: application/json

grant_type=authorization_code&

code=cb66a21f7d9fe1a141676a563c5a7eacf&

client_id=caa0b4dffd57202a157bf46664f93c192&

client_secret=s75b058bfd9e4e0659d75b67a03334745&

redirect_uri=https://demo.akubela.com

成功返回示例

狀態碼:200

Content-Type: application/json

{
"success": true,
"timestamp": 1540869200562,
"result": {
"access_token": "ad5db2a3d3ab09e5890c4ffba9eaf3c55",
"refresh_token": "r91b9ba8bc024e23617f63f908dc15950",
"token_type": "bearer",
"expires_in": 3600
}
}

失敗返回示例

接口失敗返回



密碼模式-獲取訪問令牌

接口地址

POST /api/v1.0/invoke/open-ability/method/oauth2/token

請求參數

參數名類型位置必填說明
Content-TypeStringHeader內容類型,值爲application/x-www-form-urlencoded
AcceptStringHeader接受類型,值爲application/json
grant_typeStringBody授權類型,值爲password
client_idStringBody客戶端ID
client_secretStringBody客戶端密鑰
scopeStringBody授權範圍,值爲user
usernameStringBody賬號
passwordStringBody密碼
expires_inIntegerBody令牌過期時間,單位:秒

返回參數

參數名類型位置說明
Content-TypeStringHeader內容類型,值爲application/json
successBooleanBody判斷請求是否成功
true:成功
false:失敗
timestampIntegerBody時間戳
resultObject<result>Body返回結果

result說明

參數名類型位置說明
access_tokenStringBody訪問令牌
refresh_tokenStringBody刷新令牌
token_typeStringBody令牌類型,值爲bearer
expires_inIntegerBody令牌過期時間,單位:秒

請求示例

POST /api/v1.0/invoke/open-ability/method/oauth2/token

Content-Type: application/x-www-form-urlencoded

Accept: application/json

grant_type=password&

client_id=caa0b4dffd57202a157bf46664f93c192&

client_secret=s75b058bfd9e4e0659d75b67a03334745&

username=ucaa0b4dffd57202a157bf46664f93c19&

password=pucaa0b4dffd57202a157bf46664f93c1&

scope=user

成功返回示例

狀態碼:200

Content-Type: application/json

{
"success": true,
"timestamp": 1540869200562,
"result": {
"access_token": "ad5db2a3d3ab09e5890c4ffba9eaf3c55",
"refresh_token": "r91b9ba8bc024e23617f63f908dc15950",
"token_type": "bearer",
"expires_in": 3600
}
}

失敗返回示例

接口失敗返回



刷新訪問令牌

接口地址

POST /api/v1.0/invoke/open-ability/method/oauth2/token

請求參數

參數名類型位置必填說明
Content-TypeStringHeader內容類型,值爲application/x-www-form-urlencoded
AcceptStringHeader接受類型,值爲application/json
grant_typeStringBody授權類型,值爲refresh_token
client_idStringBody客戶端ID
client_secretStringBody客戶端密鑰
refresh_tokenStringBody刷新令牌
expires_inIntegerBody令牌過期時間,單位:秒

返回參數

參數名類型位置說明
Content-TypeStringHeader內容類型,值爲application/json
successBooleanBody判斷請求是否成功
true:成功
false:失敗
timestampIntegerBody時間戳
resultObject<result>Body返回結果

result說明

參數名類型位置說明
access_tokenStringBody訪問令牌
refresh_tokenStringBody刷新令牌
token_typeStringBody令牌類型,值爲bearer
expires_inIntegerBody令牌過期時間,單位:秒

請求示例

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
}
}

失敗返回示例

接口失敗返回