Spring social facebook login error - Numeric value out of range of int

前端 未结 4 1635
闹比i
闹比i 2020-12-11 17:21

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         


        
4条回答
  •  半阙折子戏
    2020-12-11 18:15

    Update

    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.

    
        org.springframework.social
        spring-social-facebook
        2.0.3.RELEASE
    
    

    Old answer

    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

提交回复
热议问题