security oauth2报错Access Denied
时间: 2024-05-17 09:14:13 浏览: 24
引用中的代码片段是一个自定义的异常类`ForbiddenException`,它继承自`ExtendOAuth2Exception`。该异常类用于表示拒绝访问的异常,其中`getOAuth2ErrorCode()`方法返回错误码为"access_denied---拒绝访问",`getHttpErrorCode()`方法返回HTTP状态码为403(禁止访问)。
引用中的代码片段是关于配置异常翻译器的部分。在Spring Security OAuth2中,通过配置异常翻译器可以对异常进行自定义处理。在该配置类的`configure()`方法中,使用`.exceptionTranslator()`方法设置了一个自定义的异常解析器`Auth2ResponseExceptionTranslator`。
引用中提到了在Spring Boot和Vue整合的过程中,可能会出现登录报错"Access is denied"或NullPointerException。具体的实现流程包括用户登录验证、查询用户权限列表并存储到Redis中,将用户名存储在token中并放置在cookie中,请求头中携带token值,Security从header中获取token并解析出用户名,然后根据用户名查询权限列表,并给用户赋予相应的权限。
综上所述,当出现Security OAuth2报错"Access Denied"时,可能是由于用户权限不足或配置错误引起的。可以通过调试或查看日志来确定具体的原因,并根据需要进行相应的处理,例如检查用户的权限配置、确保用户在登录时正确获取到了正确的token等。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [SpringSecurity OAuth2异常处理OAuth2Exception](https://blog.csdn.net/CSDN877425287/article/details/120579509)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [SpringBoot+vue整合了SpringSecurity登录报错:Access is denied或NullPointerException](https://blog.csdn.net/weixin_52450674/article/details/115306468)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)