I used version 2.0.3.RELEASE of spring-social-facebook and Facebook app api v2.8. I called Facebook login but returned this message. "(#12) bio field is deprecated for versions v2.8 and higher" How can i fix this?
An error message is a message displayed to the user by an operating system or application when an unexpected condition happens. In most cases, error messages are displayed with the help of dialog boxes by the operating system or application.
A good error message has three parts: problem identification, cause details if helpful, and a solution if possible. Whenever an error occurs, user wants to fix it as soon as possible. The error message should have enough information for user that guides him how to get out of the erroneous situation.
Frequently displayed error messages are a sign of bad error message UX. Error messages disrupt the user experience and create friction. Thus, they should only be used in important situations like destructive actions (such as deletions). The infrequency of alerts helps ensure that people take them seriously.
I got the same error, 2.0.3.RELEASE of spring-social-facebook seems to be not compatible with v2.8 Facebook API version (released yesterday). Reading from facebook changelog for the v2.8 (https://developers.facebook.com/docs/apps/changelog):
User Bios - The bio field on the User object is no longer available. If the bio field was set for a person, the value will now be appended to the about field.
I think we have to wait a new release of spring-social-facebook library. In the release 2.0.3 (in the interface org.springframework.social.facebook.api.UserOperations) there is the "bio" field in the PROFILE_FIELDS constant and it is not supported in the v2.8 facebook API version.
UPDATE: I found a workaround in my case:
BEFORE:
Connection<Facebook> connection = facebookConnectionFactory.createConnection(accessGrant); Facebook facebook = connection.getApi(); User userProfile = facebook.userOperations().getUserProfile();//raises the exception caused by the "bio" field.
AFTER
Connection<Facebook> connection = facebookConnectionFactory.createConnection(accessGrant); Facebook facebook = connection.getApi(); String [] fields = { "id", "email", "first_name", "last_name" }; User userProfile = facebook.fetchObject("me", User.class, fields);
Here a complete list of field you could use:
{ "id", "about", "age_range", "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", "video_upload_limits", "viewer_can_send_gift", "website", "work"}
Workaround for JHipster. Add the following snippet into your SocialService
class until spring-social-facebook
is fixed.
import java.lang.reflect.Field; import java.lang.reflect.Modifier; import javax.annotation.PostConstruct; @PostConstruct private void init() { try { String[] fieldsToMap = { "id", "about", "age_range", "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(); } }
Source: https://github.com/jhipster/generator-jhipster/issues/2349 - minus bio
in fieldsToMap
array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With