2

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)?

Abhishek Singh
  • 1,367
  • 1
  • 22
  • 46
  • Should not matter much even if they didn’t, because API calls specifying an outdated API version are automatically converted to using the lowest currently available version. – CBroe Mar 19 '18 at 07:55
  • @CBroe: could you please elaborate it more. Actually what i see in spring-social jar, it is using hardcoded graph version 2.5. So how it will point to lowest available version automatically. We are actually worry taking Production app, will it work properly? – Abhishek Singh Mar 22 '18 at 06:18
  • Facebook takes care of that on their end - your app makes a request using an API version that is not available any more, so they automatically & silently treat it as if it was made using the lowest available version. – CBroe Mar 22 '18 at 07:24
  • Thanks @CBroe. you seem very accurate to me. But my company is not relying on your words until they see any proof from Facebook. It's a question of their production app used by half million users. So can you share any written document which shows it? if possible. Or any other source. – Abhishek Singh Mar 26 '18 at 07:08
  • _“It's a question of their production app used by half million users”_ - good for them. Although in that case, I’d have expected them to properly prepare for this themselves to begin with ... and not outsource it to SO last minute. – CBroe Mar 26 '18 at 07:14
  • 4
    Official Facebook documentation that backs up @CBroe's statement: https://developers.facebook.com/docs/apps/versions. It says "For APIs, once a version is no longer usable, any calls made to it will be defaulted to the next oldest usable version." – idungotnosn Mar 28 '18 at 00:42

3 Answers3

6

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

  }
...
}
Marek Raki
  • 3,056
  • 3
  • 27
  • 50
0

We can simply change api version by following way

FacebookTemplate facebookTemplate=new FacebookTemplate(accessToken);
facebookTemplate.setApiVersion("3.2");
System.out.println("graph url"+facebookTemplate.getBaseGraphApiUrl());
0

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

They recommand to simply use Spring Security instead.

Mehdi
  • 1,340
  • 15
  • 23