2018/11/18初始化 2018/11/21更新
1.调用登录接口
Request URL:http://localhost:8090/userservice/login
Request Body:
{
"account":"110112",
"password":"123456"
}
后台处理逻辑:
先查询数据校验用户基本信息
校验用通过调用microservice-base-oauth(Feign)获取token
2.获取用户基本信息
a.直接通过access_token
Request URL:http://localhost:8090/userservice/user?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiYXBpIl0sImV4cCI6MTU0MjU4MTQ4MiwidXNlcl9uYW1lIjoiMTEwMTEyIiwianRpIjoiMzQ5Mzc5N2YtNTYxNi00ODc2LThmYTEtZmRiMDQ5YTcxNTliIiwiY2xpZW50X2lkIjoiY2xpZW50XzIiLCJzY29wZSI6WyJzZXJ2ZXIiXX0.HhEkWQBhsFso6biXykTUdsGh6fvHAW87O1UYJexEdi8
b.token放在Header
key value
Authorization Bearer {access_token}
注意:value 前必须加Bearer,否则401
注意需要在microservice-base-gateway-dev.properties修改对应敏感头信息
1.登录
Request URL:http://localhost:8084/user-api/userservice/login
Request Body:
{
"account":"110112",
"password":"123456"
}
Response Body:
token信息
2.获取用户信息(方法一)
Request URL:http://localhost:8084/user-api/userservice/user?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiYXBpIl0sImV4cCI6MTU0MjU4MjI3MCwidXNlcl9uYW1lIjoiMTEwMTEyIiwianRpIjoiMWNmOWQ3NTgtNTY0Ny00YzM4LThjZmUtNWI5OTBhZWM0Mzc3IiwiY2xpZW50X2lkIjoiY2xpZW50XzIiLCJzY29wZSI6WyJzZXJ2ZXIiXX0.wPo4G0-EYNewtWStTt3fV6ljLU1wRi1pi89hy2FAEd0
Response Body:
张三
3..获取用户信息(方法二)
Request URL:http://localhost:8084/user-api/userservice/user
Request Header:
"Authorization" "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiYXBpIl0sImV4cCI6MTU0MjgwNzE2NCwidXNlcl9uYW1lIjoiMTEwMTEyIiwianRpIjoiZmI2ZmUzYjUtNTRhYi00YzBhLTkxYmYtYmNhNzJjMTQxM2JkIiwiY2xpZW50X2lkIjoiY2xpZW50XzIiLCJzY29wZSI6WyJzZXJ2ZXIiXX0.MdfcA-6DxLrPn3EzRz03eqQGAMWbNhe7sGseAAD2-SQ"
Response Body:
张三
4.博客服务测试
Request URL:http://localhost:8084/blog-api/blogservice/blog
Request Header:
"Authorization" "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiYXBpIl0sImV4cCI6MTU0MjgwNzE2NCwidXNlcl9uYW1lIjoiMTEwMTEyIiwianRpIjoiZmI2ZmUzYjUtNTRhYi00YzBhLTkxYmYtYmNhNzJjMTQxM2JkIiwiY2xpZW50X2lkIjoiY2xpZW50XzIiLCJzY29wZSI6WyJzZXJ2ZXIiXX0.MdfcA-6DxLrPn3EzRz03eqQGAMWbNhe7sGseAAD2-SQ"
Response Body:
测试博客服务器
4.在博客服务中通过Feign调用用户服务[这里采坑了]
Request URL:http://localhost:8084/blog-api/blogservice/user
Request Header:
"Authorization" "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiYXBpIl0sImV4cCI6MTU0MjgwNzE2NCwidXNlcl9uYW1lIjoiMTEwMTEyIiwianRpIjoiZmI2ZmUzYjUtNTRhYi00YzBhLTkxYmYtYmNhNzJjMTQxM2JkIiwiY2xpZW50X2lkIjoiY2xpZW50XzIiLCJzY29wZSI6WyJzZXJ2ZXIiXX0.MdfcA-6DxLrPn3EzRz03eqQGAMWbNhe7sGseAAD2-SQ"
Response Body:
张三
git地址:https://gitee.com/niugangxy/springcloudAction-JWT-V2
微信公众号
JAVA程序猿成长之路
分享学习资源,学习方法,记录程序员生活。