[英]why Spring social facebook -2.0.3 using deprecated graph api version 2.5 which is deprecated
We are using spring-social-facebook-2.0.3 latest jar in production environment.我们在生产环境中使用 spring-social-facebook-2.0.3 最新的 jar。
In April 2018 graph api v2.5 is going to shut down. 2018 年 4 月,graph api v2.5 将关闭。 But the spring-social-facebook-2.0.3 latest jar is still using this deprecated graph API internally.但是 spring-social-facebook-2.0.3 最新的 jar 仍在内部使用这个已弃用的图形 API。
Anyone has any knowledge,任何人有任何知识,
is Spring Team going to release new version of spring-social-facebook till next month (ie April 2018)? Spring Team 会在下个月(即 2018 年 4 月)之前发布新版本的 spring-social-facebook 吗?
Solution for those who wants to change used API version in 2.0.3 Release and Facebook API Upgrade Tool says it does not affect them applications:对于那些想要更改 2.0.3 版本中使用的 API 版本和 Facebook API 升级工具的人的解决方案表示它不会影响他们的应用程序:
public class FacebookCustomApiVersionConnectionFactory extends OAuth2ConnectionFactory<Facebook> {
public FacebookCustomApiVersionConnectionFactory(String apiVersion, String appId, String appSecret) {
super("facebook", new FacebookCustomApiVersionServiceProvider(apiVersion, appId, appSecret, null), new FacebookAdapter());
}
}
/**
* Facebook ServiceProvider implementation that allows to change Facebook API version.
*/
public class FacebookCustomApiVersionServiceProvider extends AbstractOAuth2ServiceProvider<Facebook> {
private final String appNamespace;
private final String apiVersion;
/**
* Creates a FacebookServiceProvider for the given API version, application ID, secret, and namespace.
*
* @param apiVersion Facebook API version
* @param appId The application's App ID as assigned by Facebook
* @param appSecret The application's App Secret as assigned by Facebook
* @param appNamespace The application's App Namespace as configured with Facebook. Enables use of Open Graph operations.
*/
public FacebookCustomApiVersionServiceProvider(String apiVersion, String appId, String appSecret, String appNamespace) {
super(getOAuth2Template(apiVersion, "https://graph.facebook.com/v" + apiVersion + "/", appId, appSecret));
this.apiVersion = apiVersion;
this.appNamespace = appNamespace;
}
private static OAuth2Template getOAuth2Template(String apiVersion, String graphApiUrl, String appId, String appSecret) {
OAuth2Template oAuth2Template = new OAuth2Template(appId, appSecret,
"https://www.facebook.com/v" + apiVersion + "/dialog/oauth",
graphApiUrl + "oauth/access_token");
oAuth2Template.setUseParametersForClientAuthentication(true);
return oAuth2Template;
}
public Facebook getApi(String accessToken) {
FacebookTemplate facebook = new FacebookTemplate(accessToken, appNamespace);
facebook.setApiVersion(apiVersion);
return facebook;
}
}
Spring social configuration春季社交配置
@Configuration
@EnableSocial
public class SocialConfiguration implements SocialConfigurer {
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
cfConfig.addConnectionFactory(new FacebookCustomApiVersionConnectionFactory("2.7", "appId","appSecret");
}
...
}
We can simply change api version by following way我们可以通过以下方式简单地更改api版本
FacebookTemplate facebookTemplate=new FacebookTemplate(accessToken);
facebookTemplate.setApiVersion("3.2");
System.out.println("graph url"+facebookTemplate.getBaseGraphApiUrl());
That project is obselete.那个项目已经过时了。 They announced the end of life in 2018 to be effective in 2019: https://spring.io/blog/2018/07/03/spring-social-end-of-life-announcement他们宣布 2018 年生命终结于 2019 年生效: https ://spring.io/blog/2018/07/03/spring-social-end-of-life-announcement
They recommand to simply use Spring Security instead.他们建议改用 Spring Security。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.