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

授权认证API


客户端模式-获取访问令牌

接口地址

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

请求参数

参数名类型位置必填说明
Content-TypeStringHeader内容类型,值为application/x-www-form-urlencoded
AcceptStringHeader接受类型,值为application/json
grant_typeStringBody授权类型,值为client_credentials
client_idStringBody客户端ID
client_secretStringBody客户端密钥
scopeStringBody授权范围,值为hotel
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=client_credentials&

client_id=caa0b4dffd57202a157bf46664f93c192&

client_secret=s75b058bfd9e4e0659d75b67a03334745&

scope=hotel

成功返回示例

状态码: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-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
}
}

失败返回示例

接口失败返回