首页

解决项目OAuth2测试接口需Please sign in登录授权认证..否则postman报“401 Unauthorized..”报错

标签:oauth2,postman认证配置     发布时间:2022-06-29   

一、问题描述

项目基于Oauth2安全认证框架,测试接口时跳转其认证登录页面http://localhost:8081/login(如下图1),另外通过postman访问报“401 Unauthorized..”如下图2报错

解决项目OAuth2测试接口需Please sign in登录授权认证..否则postman报“401 Unauthorized..”报错

(图1)

解决项目OAuth2测试接口需Please sign in登录授权认证..否则postman报“401 Unauthorized..”报错

(图2)

二、解决方法

1、在启动日志查找关键词“Using generated security password:”如下日志所示

security password2022-06-27 16:13:35.062  INFO 23716 --- [isson-netty-4-1] o.r.c.pool.MasterPubSubConnectionPool    : 1 connections initialized for 127.0.0.1/127.0.0.1:6379@b@2022-06-27 16:13:35.066  INFO 23716 --- [isson-netty-4-1] o.r.c.pool.MasterConnectionPool          : 32 connections initialized for 127.0.0.1/127.0.0.1:6379@b@2022-06-27 16:13:36.228  INFO 23716 --- [           main] .s.s.UserDetailsServiceAutoConfiguration : @b@@b@Using generated security password: b83c605d-dbe4-499f-a6b6-bce2ed9b0379

2、在上面图1界面输入Username=user,Password=b83c605d-dbe4-499f-a6b6-bce2ed9b0379即可

3、打开postman工具,如下图将2中用户密码配置进去,点击“Send”按钮即可

解决项目OAuth2测试接口需Please sign in登录授权认证..否则postman报“401 Unauthorized..”报错

另外,可以参考其他文章跳过OAuth2认证