纳加服务器授权文件,五认证服务器授权模式

授权码模式

密码模式

客户端模式

简化模式

刷新token模式

(1)密码模式

http://localhost/oauth/token?username=user&password=user&grant_type=password&client_id=client&client_secret=secret

grant_type:授权类型,必选,此处固定值“password”

username:表示用户名,必选

password:表示用户密码,必选

scope:权限范围,可选

(2)授权码模式

client_id:客户端ID,必选

response_type:必须为code,必选

redirect_uri:回掉url,必选

获取授权码:

http://localhost/oauth/authorize?client_id=client&response_type=code&redirect_uri=http://localhost:9001/auth_user/get_auth_code

获取access_token

http://localhost/oauth/token?grant_type=authorization_code&code=XQfMUi&client_id=client&client_secret=secret&redirect_uri=http://localhost:9001/auth_user/get_token_info

通过refresh_token获取access_token

http://localhost/oauth/token?grant_type=refresh_token&refresh_token=Beared5d74d532ba446b58f78186013f5e170&client_id=client&client_secret=se

(3)客户端模式:

指客户端以自己的名义,而不以用户的名义,向"服务提供商"进行认证。在这种模式中,用户直接向客户端注册,客户端以自己的名义要求"服务提供商"提供服务,其实不存在授权问题。

请求格式:POST   -D

"http://localhost/OAuth/token?client_id=appid&grant_type=client_credentials&client_secret=appkey"

granttype:表示授权类型,此处的值固定为"clientcredentials",必选项。

scope:表示权限范围,可选项。

(4)刷新token

http://localhost/oauth/token?grant_type=refresh_token&refresh_token=token&client_id=client&client_secret=secret

其中grant_type为固定值:grant_type=refresh_token

2传递token三种方式

header添加Authorization

Authorization:Bearer a.b.c

参数添加access_token

/api/a?access_token=a.b.c

cookie添加access_token

access_token=a.b.c

3校验token

检查头肯是否有效请求(/oauth/check_token)

http://localhost/oauth/check_token?token=f57ce129-2d4d-4bd7-1111-f31ccc69d4d1

请求所需参数:token

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值