欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

spring boot security oauth2 jwt

程序员文章站 2022-06-13 19:59:23
...


项目源码下载:

https://github.com/alexleolab/spring-oauth.git


测试过程
步骤一:打开浏览器,输入地址

http://localhost:1130/oauth/authorize?client_id=normal-app&response_type=code&scope=read&redirect_uri=/resources/user


用户名alex

密码test


spring boot security oauth2 jwt

spring boot security oauth2 jwt


点击Authorize获取code

spring boot security oauth2 jwt



 打开工具postman,输入以下地址获取授权token,Authorization那一栏选择Basic Auth ,用户名填入normal-app,密码不填
localhost:1130/oauth/token?code=Yourcode&grant_type=authorization_code&client_id=normal-app&redirect_uri=/resources/user

spring boot security oauth2 jwt


spring boot security oauth2 jwt





这时候拿到token就可以访问受保护的资源信息了,如下

localhost:8081//resources/user?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsic3ByaW5nLWJvb3QtYXBwbGljYXRpb24iXSwidXNlcl9uYW1lIjoibGVmdHNvIiwic2NvcGUiOlsicmVhZCJdLCJyb2xlcyI6W3siYXV0aG9yaXR5IjoiUk9MRV9VU0VSIn1dLCJleHAiOjE0OTEzNTkyMjksInVzZXJOYW1lIjoibGVmdHNvIiwiYXV0aG9yaXRpZXMiOlsiUk9MRV9VU0VSIl0sImp0aSI6IjgxNjI5NzQwLTRhZWQtNDM1Yy05MmM3LWZhOWIyODk5NmYzMiIsImNsaWVudF9pZCI6Im5vcm1hbC1hcHAifQ.YhDJkMSlyIN6uPfSFPbfRuufndvylRmuGkrdprUSJIM

spring boot security oauth2 jwt

spring boot security oauth2 jwt