springcloud搭建Oauth2.0开放平台-效果(2)

在Spring Cloud需要使用oauth2来实现多个微服务的统一认证授权,通过向OAUTH服务发送某个类型的grant type进行集中认证和授权,从而获得access_token,而这个token是受其他微服务信任的,我们在后续的访问可以通过access_token来进行,从而实现了微服务的统一认证授权。

客户端根据约定的ClientID、ClientSecret、Scope来从Access Token URL地址获取AccessToken,并经过AuthURL认证,用得到的AccessToken来访问其他资源接口。

 Spring Cloud oauth2 需要依赖Spring security

1、获取授权码,回调返回code(code有效期10分钟,使用过后必须重新获取),如下图:

http://localhost:8115/oauth/authorize?response_type=code&client_id=client_1&redirect_uri=http://www.baidu.com

2、授权码模式:通过code,获取accessToken,如下图:

http://localhost:8115/oauth/token?grant_type=authorization_code&code=wOWRd9&redirect_uri=http://www.baidu.com&scope=all&client_id=client_1&client_secret=123456

3、密码模式:通过用户名和密码,获取accessToken,如下图:

 http://localhost:8115/oauth/token?grant_type=password&redirect_uri=http://www.mayikt.com&scope=all&username=user_1&password=123456&client_id=client_1&client_secret=123456

4、刷新token

http://localhost:8115/oauth/token?grant_type=refresh_token&refresh_token=02521fd5-5233-4c80-b12a-231bef1c1a14&client_id=client_1&client_secret=123456

5、检查token有效期:

http://localhost:8115/oauth/check_token?token=2eee1e81-d14c-4d24-91f6-42d4d3c4a348

6、客户端访问

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值