应用级别的accessToken用于应用调用技术服务时(如短信邮件服务、云文档等),提供应用认证信息
用户级别的accessToken用于管理用户信息(增删改查)
accessToken特性说明:
POST http://account.hsifue.cn/v3/api/oauth2/token
| 参数名 | 参数值 | 必选 | 类型 | 描述 |
|---|---|---|---|---|
| Authorization | Basic ******************** | 是 | String | Basic后面为 Base64(AppKey:AppSecret) |
| Content-Type | application/x-www-form-urlencoded | 是 | String |
| 参数名 | 必选 | 类型 | 描述 |
|---|---|---|---|
| grant_type | 是 | String | 授权类型,不同的grantType需要不同的传值: password:通过账号、密码方式获取用户级accessToken refresh_token:通过refreshToken获取accessToken client_credentials:通过Header 认证头获取应用级accessToken uid:通过userId免密获取用户级accessToken(需要额外申请权限,非必要不开放) sms:通过短信验证码获取用户级accessToken |
| username | 否 | String | 用户登录名,当password模式时需要,当grant_type为sms时,填写手机号 |
| password | 否 | String | 密码,当password模式时需要密码错误,多次尝试账号被锁(15次/分钟,25次/5分钟)。path传值时注意对特殊字符进行urlencode |
| refresh_token | 否 | String | 刷新accessToken,当refresh_token模式时需要 |
| uid | 否 | Long | 当grant_type为uid模式时需要,广联云账号用户id |
| code | 否 | String | 当grant_type为sms时,该参数是手机验证码,其他情况可以省略(未注册的手机号登陆后自动注册) |
| HTTP 代码 | code | message(中文/英文) | 说明 |
|---|---|---|---|
| 200 | 0 | 操作成功/ok | 成功请求 |
| 11100 | 当前账户未授权/account.unauthorized | 账号被锁定 | |
| 11101 | 用户名或者密码无效/account.username.or.password.invalid | ||
| 11103 | 账户未激活/account.identitiy.not.verified | ||
| 11202 | 授权方式(grant type)不正确/ account.oauth.unauthorized.grant.type |
||
| 11402 | appKey或appSecret无效/app.key.or.secret.invalid | ||
| 10002 | 参数无效/invalid.parameters | ||
| 11102 | 验证码错误/account.mobile.verify.code.invalid | sms登录时验证码错误 |
curl --request POST 'http://account.hsifue.cn/v3/api/oauth2/token' \
--header 'Authorization: Basic QnVZY2************************JPbUE=' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username=138****8888' \
--data-urlencode 'password=**********'
{
"code": 0,
"message": "操作成功",
"data": {
"access_token": "cn-c4e7bae******************018058",
"token_type": "bearer",
"refresh_token": "cn-ebb0b3******************a21656",
"expires_in": 604799,
"scope": "account_info_write account_info_write account_token_login colibri_email"
}
}
{
"code": 11101,
"message": "用户名或者密码无效",
"data": "username not found at invite table"
}