Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oauth 2+;Spring安全性-获取403禁止的错误_Spring_Spring Mvc_Spring Security_Oauth 2.0_Spring Security Oauth2 - Fatal编程技术网

Oauth 2+;Spring安全性-获取403禁止的错误

Oauth 2+;Spring安全性-获取403禁止的错误,spring,spring-mvc,spring-security,oauth-2.0,spring-security-oauth2,Spring,Spring Mvc,Spring Security,Oauth 2.0,Spring Security Oauth2,我使用Spring框架创建了一个简单的web应用程序客户端。我正在使用OAuth2RestTemplate调用需要TLS/SSL连接的第三方REST服务。我已经将Tomcat配置为使用HTTPS端口,并指定了我创建的密钥库文件。我还向第三方资源提供商注册了在Tomcat localhost上运行的客户端应用程序。我在安全配置XML文件中指定了客户机id、密码和其他详细信息。我在注册web客户端时选择了“授权码授权类型” 当我发出请求时,我被重定向到web客户端的表单登录。在那里进行身份验证后,我

我使用Spring框架创建了一个简单的web应用程序客户端。我正在使用OAuth2RestTemplate调用需要TLS/SSL连接的第三方REST服务。我已经将Tomcat配置为使用HTTPS端口,并指定了我创建的密钥库文件。我还向第三方资源提供商注册了在Tomcat localhost上运行的客户端应用程序。我在安全配置XML文件中指定了客户机id、密码和其他详细信息。我在注册web客户端时选择了“授权码授权类型”

当我发出请求时,我被重定向到web客户端的表单登录。在那里进行身份验证后,我被重定向到第三方资源提供商站点,以对用户进行身份验证。当我输入用户名和密码时,我会看到需要授权或拒绝请求的页面。在此之后,我得到403禁止错误。当我查看第三方REST服务提供商站点时,我可以看到为我的POST请求生成了一个令牌。日志还指示Http代码200 Ok的相同情况。但是我相信,当使用令牌访问资源时,使用我请求的Get调用时,我得到了403个禁止的错误

我花了相当长的时间调试和研究这个问题,但到目前为止没有运气。任何帮助都将不胜感激

下面是我的一些代码片段

security config.xml


我的控制器:

@控制器
公共类控制器
{   
字符串端点=RESTAPI端点;
@自动连线
私有OAuth2RestTemplate到AuthTemplate;
@请求映射(“/tEventDetails.html”)
公共模型和视图getEventDetails(){
List tEventData=(List)tOAuthTemplate.getForObject(endPoint+“tEvents”,TEvent.class).getData();
返回新的ModelAndView(“/tDetailsPage.jsp”,“tDetails”,tEventData);
}
}
重定向到:

以下是日志中的一些片段:

13:10:34957调试org.springframework.beans.factory.support.DefaultListableBeanFactory:449-创建bean'scopedTarget.org.springframework.security.oauth2.client.token.DefaultAccessTokenRequest#1'的实例
13:10:34960调试org.springframework.beans.factory.support.DefaultListableBeanFactory:477-已完成bean'scopedTarget.org.springframework.security.oauth2.client.token.DefaultAccessTokenRequest#1'实例的创建
13:10:34968调试org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider:159-从*******thirdpartyhost/oauth2/ss/token检索令牌
13:10:34982调试org.springframework.web.client.RestTemplate:78-已为“创建POST请求”https://thirdpartyhost/ss/super/token"
13:10:34983调试org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider:221-编码和发送格式:{grant_type=[authorization_code],code=[cjtjlstkw7uzt7rvim0xq3ogl],重定向_uri=[**localhost:8443/mm/tDetails.html]]
***13:10:35383调试org.springframework.web.client.RestTemplate:569-对“***第三方主机/ss/oauth2/token”的POST请求导致200(确定)
13:10:35403调试***org.springframework.web.client.HttpMessageConverterExtractor:92-使用[org.springframework.http.converter.json]将[interface org.springframework.security.oauth2.common.OAuth2AccessToken]读取为“application/json”。MappingJackson2HttpMessageConverter@4997b84c]
13:10:35600调试org.springframework.security.oauth2.client.OAuth2RestTemplate:78-为“******第三方主机/v7/ss/me/tEvents?limit=5”创建GET请求
13:10:35628调试org.springframework.security.oauth2.client.OAuth2RestTemplate:669-将请求接受头设置为[application/json,application/*+json]
13:10:35797警告***org.springframework.security.oauth2.client.OAuth2RestTemplate:581-获取“*****thirdpartyhost/v7/ss/tEvents”请求导致403(禁止);调用错误处理程序***
13:10:35804调试org.springframework.web.client.HttpMessageConverterExtractor:92-使用[org.springframework.http.converter.json]将[class org.springframework.security.oauth2.common.exceptions.OAuth2Exception]读取为“application/json;charset=UTF-8”。MappingJackson2HttpMessageConverter@161bd9ce]
13:10:35806调试org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver:134-从处理程序[com.pvp.webcontroller]解析异常。TCERefAppController@4c233b11]:org.springframework.web.client.httpclienterror异常:403禁止
13:10:35807调试org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver:134-从处理程序[com.pvp.webcontroller]解析异常。TCERefAppController@4c233b11]:org.springframework.web.client.httpclienterror异常:403禁止
13:10:35807调试org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver:134-从处理程序[com.pvp.webcontroller]解析异常。TRefAppController@4c233b11]:org.springframework.web.client.httpclienterror异常:403禁止
13:10:35807调试org.springframework.web.servlet.DispatcherServlet:984-无法完成请求
org.springframework.web.client.httpclienterror异常:403禁止
位于org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
位于org.springframework.security.oauth2.client.http.OAuth2ErrorHandler.handleError(OAuth2ErrorHandler.java:165)
位于org.springframework.web.client.restemplate.handleResponseError(restemplate.java:588)
位于org.springframework.web.client.restemplate.doExecute(restemplate.java:546)
位于org.springframework.security.oauth2.client.OAuth2RestTemplate.doExecute(OAuth2RestTemplate.java:128)
从日志中我可以看到帖子