如何处理spring社交facebook中发生的ExpiredAuthorizationException?
我可以将facebook api与Spring Social一起使用几天(3个月或更长),但现在出现了异常“org.springframework.Social.ExpiredAuthorizationException:授权已过期” 因此,我调查了自spring social版本1.1.0.M3以来通过重新连接过滤器解决的问题,但即使按照建议,我也无法更新令牌如何处理spring社交facebook中发生的ExpiredAuthorizationException?,spring,spring-social,spring-social-facebook,Spring,Spring Social,Spring Social Facebook,我可以将facebook api与Spring Social一起使用几天(3个月或更长),但现在出现了异常“org.springframework.Social.ExpiredAuthorizationException:授权已过期” 因此,我调查了自spring social版本1.1.0.M3以来通过重新连接过滤器解决的问题,但即使按照建议,我也无法更新令牌 如何从该异常中恢复?在对我最终解决的代码进行了大量分析后,我直接修改了代码,以改变spring social core中OAuth2C
如何从该异常中恢复?在对我最终解决的代码进行了大量分析后,我直接修改了代码,以改变spring social core中OAuth2Connection类通过spring social core的特殊过滤器(重新连接过滤器)引发ExpiredAuthorizationException异常的方式(自版本1.1.0.M3起包含) 为此,在社交配置中设置重新连接过滤器的bean
@Bean
public ReconnectFilter apiExceptionHandler() {
return new ReconnectFilter(usersConnectionRepository, userIdSource()) ;
}
不要忘记在web.xml中设置过滤器
<filter>
<filter-name>apiExceptionHandler</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>apiExceptionHandler</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
apiExceptionHandler
org.springframework.web.filter.DelegatingFilterProxy
apiExceptionHandler
/*
最后需要修改的是org.springframework.social.connect.support.OAuth2Connection
class of modulespring social core
抛出ExpiredAuthorizationException
exception ofExpiredAuthorizationException(null)
到抛出new to ExpiredAuthorizationException(getKey().getProviderId())
之后,过滤器将删除旧的facebook连接,并通过ConnectController
的/connect/facebook?reconnect=true
中的帖子创建一个新的facebook连接
使用了1.1.0.M4版social spring