OAuth2授权
http://pre.sovell.com/oauth/v2/authorize
http://pre.sovell.com/oauth/v2/token
http://pre.sovell.com/oauth/v2/check_token
- 测试环境终端信息
client_id=B-8onb81TPCog2YBhSsQaA
client_secret=q1LQuI8C4CI
- 生产环境Oauth2地址
http://pass.sovell.com/oauth/v2/authorize
http://pass.sovell.com/oauth/v2/token
http://pass.sovell.com/oauth/v2/check_token
- 生产环境终端信息根据实际情况配置
终端方式授权
- 这种方式只对client进行授权,没有用户信息
- 详见 rfc6749
-
接口调用示例
POST /oauth/v2/token HTTP/1.1 Host: pre.sovell.com Content-Type: application/x-www-form-urlencoded grant_type=client_credentials&client_id=B-8onb81TPCog2YBhSsQaA&client_secret=q1LQuI8C4CI- grant_type必须为client_credentials
短信授权
- 短信授权实际上扩展了code方式的授权过程
-
发送给某个手机
GET /oauth/v2/code?phone=17868424633&title=我的短信 HTTP/1.1 Host: ${domain} Authorization: Bearer ${token} -
发送成功后不返回实际内容,HttpStatus=200即为成功
-
成功后调用/token接口
- 手机收到的授权码作为code参数
- 可参考文档rfc6749
二维码授权
- 二维码授权实际上扩展了code方式的授权过程
-
取CODE
GET /oauth/v2/session/${session}/code HTTP/1.1 Host: ${domain} Authorization: Bearer ${token}参数名 类型 说明 session string 由生成端生成,此参数全局唯一,可能会与其他生成端冲突,需要做好重试机制 -
调用成功后返回code
- 当调用失败时,请做好重试机制
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 { "code": "${code}" }状态码 说明 200 成功 409 session重复 参数名 类型 说明 code 一般用于生成二维码 -
调用/token接口
- 子系统通过二维码解码作为code参数
- 可参考文档rfc6749 4.1.3
-
调用扫码状态接口
- 一般由生产二维码端发起,用于展示二维码扫码结果
- 对于不需要知道二维码是否使用的场景可跳过本步骤
GET /oauth/v2/session/${session}/state HTTP/1.1 Host: ${domain} Authorization: Bearer ${token}参数名 类型 说明 session string 与生成时使用相同值 -
得到扫码状态结果
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 { "code": "${state}" }参数名 类型 说明 state 状态 used 已使用 unused 未使用
物理卡授权
-
读出物理卡号
-
调用/token接口
- 将
物理卡号以card/${物理卡号}的形式赋值code - grant_type=offline_cert
POST /oauth/v2/token HTTP/1.1 Host: dev.sovell.com Content-Length: 96 Content-Type: application/x-www-form-urlencoded code=card/001&client_id=fzU1cb7ESpuaVRThuBcYcQ&client_secret=abc&grant_type=offline_cert - 将
-
返回token
- 返回roles中会附加card角色
-
st卡状态,lost表示挂失,不输出表示正常
HTTP/1.1 200 OK Server: nginx/1.11.6 Date: Thu, 25 Oct 2018 02:09:13 GMT Content-Type: application/json;charset=utf-8 Content-Length: 254 Connection: keep-alive Cache-Control: no-store Pragma: no-cache { "access_token": "271952ee-a0b6-4360-9edd-e9052bb494d7", "token_type": "bearer", "refresh_token": "7abbd5ba-7704-4ba8-bc63-484997ce0659", "expires_in": 7199, "scope": "pass:payment openid", "sub": "6aeca60613e949f0a16e721faf9f1082", "roles": "root card", "card": "001", "st": "lost" }
交易接口
- 测试环境地址
http://pre.sovell.com/sovellpay/v2
- 生产环境地址
http://pass.sovell.com/sovellpay/v2
-
在http请求头中设置OAuth2授权返回的access_token
Authorization: Bearer ${access_token}
-
详见 交易接口