Oauth2 认证接口文档
1.获取授权码
请求地址:/oauth/authorize/ 请求方式:GET
请求参数
参数名
必填
字段类型
描述
client_id
是
String
客户端 id,新建 application 时生成
response_type
是
String
授权类型,固定为“code”
redirect_ur
是
String
重定向 URL,用户授权成功后跳转到的地址
state
否
String
用户授权后跳转地址会带上该参数
响应参数
参数名
字段类型
描述
code
string
授权成功即重定向到制定 URL 并回传授权码
请求示例
http://xxx.com/oauth/authorize/?client_id=123456&response_type=code&redirect_uri=http:
//yyy.com/yyy/
响应示例
http://yyy.com/?code=29sdEad4
2.获取令牌
请求地址:/oauth/token/ 请求方式:POST
请求参数
参数名
必填
字段类型
描述
grant_type
是
String
授权模式,固定为:authorization_code
client_id
是
String
客户端 id,新建 application 时生成
client_secret
是
String
客户端秘钥,新建 application 时生成
redirect_ur
是
String
重定向 URL,用户授权成功后跳转到的地址
code
是
String
授权码,进行 1 接口请求到的
响应参数
参数名
字段类型
描述
access_token
String
访问资源服务的令牌
token_type
String
令牌类型
refresh_token
String
更新令牌。用来获取下次的访问令牌
expires_in
Int
过期时间,单位秒
scope
String
权限范围