spring security+oauth2 实现token过期后重新获取token并跳转到原页面

楼主这里有个需求:当token过期后 重新获取token 并返回过期那页 这里主要依赖前端实现

xx.xx为前端

xx1.xx1为后端

1.当前端在 xx.xx/user token失效

2.原本获取 http://192.168.xx1.xx1:6001/oauth/authorize?client_id=user-vue&response_type=code 那么现在改成 http://192.168.xx1.xx1:6001/oauth/authorize?client_id=user-vue&response_type=code&redirect_uri=http://192.168.xx.xx:8080/excessive?
redirectTo=http://192.168.xx.xx:8080/user 

注意:redirect_uri地址需要与oauth_client_details表中的web_server_redirect_uri字段相同 否则会报错

          redirectTo中的地址为当前过期页面地址

3.这时候跳转到登录页面 当登录成功后 跳转到http://192.168.xx.xx:8080/excessive(表中配置)页面 同时后面跟着http://192.168.xx.xx:8080/excessive?redirectTo=http://192.168.xx.xx:8080/user&code=BqMKx7

4.在excessive页面中 首先调用/oauth/token 获取token 然后跳转到redirectTo=http://192.168.xx.xx:8080/user

扫描二维码关注公众号,回复: 12469976 查看本文章

猜你喜欢

转载自blog.csdn.net/qq_20143059/article/details/113766876