springfacebook-graph-apispring-social-facebook

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.

In April 2018 graph api v2.5 is going to shut down. But the spring-social-facebook-2.0.3 latest jar is still using this deprecated graph API internally.

Anyone has any knowledge,
is Spring Team going to release new version of spring-social-facebook till next month (i.e April 2018)?


Solution

  • 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:

    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");
    
      }
    ...
    }