从实战的角度谈微服务(七):对于spring security的使用
作者:互联网
gcs-spring
介绍
代码地址:(https://gitee.com/lovecheng/gcs-spring.git)
spring框架学习
获取令牌
方式一:客户端模式(client_credentials)
接口:
POST localhost:9001/oauth/token
参数:
client_id:webapp
client_secret:123456
grant_type:client_credentials
返回结果
{
"access_token": "9f985b2c-02a3-4222-b4fd-306f27412134",
"token_type": "bearer",
"refresh_token": "30ad49b0-6255-4fed-a1c8-93b1026bf53b",
"expires_in": 7200,
"scope": "all"
}
方式二:密码模式(password)
接口:
POST localhost:9001/oauth/token
参数:
client_id:webapp
client_secret:123456
grant_type:password
username:root
password:123456
方式三:简化模式(implicit)
浏览器访问
方式四:授权码模式(authorization_code)
获取code
获取令牌
接口:
POST localhost:9001/oauth/token
参数:
client_id:webapp
client_secret:123456
grant_type:authorization_code
code:cd5ybn
redirect_uri:http://www.baidu.com
方式五: 刷新令牌
接口:
POST localhost:9001/oauth/token
参数:
client_id:webapp
client_secret:123456
grant_type:refresh_token
refresh_token:30ad49b0-6255-4fed-a1c8-93b1026bf53b
令牌验证
接口
POST localhost:9001/oauth/token
参数
token:9f985b2c-02a3-4222-b4fd-306f27412134
结果
{
"aud": [
"order"
],
"user_name": "root",
"scope": [
"all"
],
"active": true,
"exp": 1645097273,
"authorities": [
"ROLE_vip2",
"ROLE_vip3",
"ROLE_vip1"
],
"client_id": "webapp"
}
标签:spring,token,client,谈微,9001,webapp,security,type,localhost 来源: https://www.cnblogs.com/lovechengyu/p/15924263.html