Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error message is (#12) bio field is deprecated for versions v2.8 and higher

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?

like image 515
Anselm Kim Avatar asked Oct 06 '16 08:10

Anselm Kim


People also ask

What does an error message?

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.

How do you write an error message?

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.

What is an error message UX?

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.


2 Answers

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"} 
like image 181
user6904265 Avatar answered Oct 27 '22 11:10

user6904265


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.

like image 37
Michal Foksa Avatar answered Oct 27 '22 11:10

Michal Foksa