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

后端 未结 9 1310
南旧
南旧 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:44

    I had problems with the new version of spring-social-facebook. To fix this using version 2.0.3.RELEASE paste the following code in your SocialService.java

    @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();
        }
    }
    

    This code will not try to retrieve bio field from Facebook.

    You can see more details here: https://github.com/jhipster/generator-jhipster/issues/2349

提交回复
热议问题