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

后端 未结 9 1305
南旧
南旧 2020-12-01 09:31

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 vers

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 09:52

    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.

提交回复
热议问题