I have a problem using Spring Social, when I tried to login to Facebook, I get the following error:
org.springframework.social.facebook.api.User[\"video_uplo
Looks like an issue with an update on facebooks side on Dec 6th 2015. I guess they allow larger video file uploads. There's a workaround described here until spring social is updated: https://github.com/spring-projects/spring-social-facebook/issues/181 (need to edit the class org.springframework.social.facebook.api.UserOperations.java, compile and put back in the spring-social-facebook-2.0.2.RELEASE.jar file).
It looks like a new release of spring-social-facebook has been created and is available already on the github page. It should be available through Maven shortly.
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-facebook</artifactId>
<version>2.0.3.RELEASE</version>
</dependency>
As long as there is no update of the library, you can also just use reflections and remove the "video_upload_limit" from UserOperations.java. So we do not need to extend/rewrite any code or have to compile our own version of the Spring Social Facebook lib.
Use the following code:
@PostConstruct
private void init() {
// hack for the facebook login
try {
String[] fieldsToMap = {
"id", "about", "age_range", "address", "bio", "birthday", "context", "cover", "currency", "devices", "education", "email",
"favorite_athletes", "favorite_teams", "first_name", "gender", "hometown", "inspirational_people", "installed", "install_type",
"is_verified", "languages", "last_name", "link", "locale", "location", "meeting_for", "middle_name", "name", "name_format",
"political", "quotes", "payment_pricepoints", "relationship_status", "religion", "security_settings", "significant_other",
"sports", "test_group", "timezone", "third_party_id", "updated_time", "verified", "viewer_can_send_gift",
"website", "work"
};
Field field = Class.forName("org.springframework.social.facebook.api.UserOperations")
.getDeclaredField("PROFILE_FIELDS");
field.setAccessible(true);
Field modifiers = field.getClass().getDeclaredField("modifiers");
modifiers.setAccessible(true);
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(null, fieldsToMap);
} catch (Exception ex) {
ex.printStackTrace();
}
}
In my case I use a configuration class for social media and I have placed a @PostConstruct method with this code in it.
Issue on github
Graph Api documentation says integer, but size response with a long:
curl "https://graph.facebook.com/v2.5/me?fields=video_upload_limits&access_token=XXX"
{"video_upload_limits":{"length":3600,"size":2505397589},"id":"1089515813"}
Opened a bug ticket for facebook team to update the documentation: https://developers.facebook.com/bugs/1660757127499390/
This snapshot works fine. Could be used as a temporary solution.
<repository>
<id>Spring Snapshot</id>
<url>http://repo.spring.io/simple/snapshot/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-facebook</artifactId>
<version>2.0.3.BUILD-SNAPSHOT</version>
</dependency>