Announcement Announcement Module
Collapse
No announcement yet.
Connecting a Fan Page-only account throws JsonMappingException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Connecting a Fan Page-only account throws JsonMappingException

    This is a pretty obscure bug. You can create a Fan Page directly from the Facebook log in page that does not have a regular Facebook profile attached to it. When you log in to this account, you are the Fan Page itself (there is a link at the top where the Facebook Profile drop down usually is that says "Create your profile").

    When I attempt to connect this account, I get the below stack trace. Thoughts?

    Code:
    org.springframework.web.client.ResourceAccessException: I/O error: Can not deserialize instance of org.springframework.social.facebook.api.FacebookProfile out of VALUE_FALSE token
     at [Source: java.io.ByteArrayInputStream@1fa3080; line: 1, column: 1]; nested exception is org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of org.springframework.social.facebook.api.FacebookProfile out of VALUE_FALSE token
     at [Source: java.io.ByteArrayInputStream@1fa3080; line: 1, column: 1]
    	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:453) ~[spring-web-3.1.0.M2.jar:3.1.0.M2]
    	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:415) ~[spring-web-3.1.0.M2.jar:3.1.0.M2]
    	at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:213) ~[spring-web-3.1.0.M2.jar:3.1.0.M2]
    	at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:173) ~[spring-social-facebook-1.0.0.RC1.jar:na]
    	at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:43) ~[spring-social-facebook-1.0.0.RC1.jar:na]
    	at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:39) ~[spring-social-facebook-1.0.0.RC1.jar:na]
    	at org.springframework.social.facebook.connect.FacebookAdapter.setConnectionValues(FacebookAdapter.java:42) ~[spring-social-facebook-1.0.0.RC1.jar:na]
    	at org.springframework.social.facebook.connect.FacebookAdapter.setConnectionValues(FacebookAdapter.java:30) ~[spring-social-facebook-1.0.0.RC1.jar:na]
    	at org.springframework.social.connect.support.AbstractConnection.setValues(AbstractConnection.java:172) ~[spring-social-core-1.0.0.RC1.jar:na]
    	at org.springframework.social.connect.support.AbstractConnection.initKey(AbstractConnection.java:135) ~[spring-social-core-1.0.0.RC1.jar:na]
    	at org.springframework.social.connect.support.OAuth2Connection.<init>(OAuth2Connection.java:73) ~[spring-social-core-1.0.0.RC1.jar:na]
    	at org.springframework.social.connect.support.OAuth2ConnectionFactory.createConnection(OAuth2ConnectionFactory.java:58) ~[spring-social-core-1.0.0.RC1.jar:na]
    	at org.springframework.social.connect.web.ConnectSupport.completeConnection(ConnectSupport.java:114) ~[spring-social-web-1.0.0.RC1.jar:na]
    	at org.springframework.social.connect.web.ConnectController.oauth2Callback(ConnectController.java:176) ~[spring-social-web-1.0.0.RC1.jar:na]
    Caused by: org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of org.springframework.social.facebook.api.FacebookProfile out of VALUE_FALSE token
     at [Source: java.io.ByteArrayInputStream@1fa3080; line: 1, column: 1]
    	at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163) ~[jackson-mapper-asl-1.8.2.jar:1.8.2]
    	at org.codehaus.jackson.map.deser.StdDeserializationContext.mappingException(StdDeserializationContext.java:198) ~[jackson-mapper-asl-1.8.2.jar:1.8.2]
    	at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeUsingCreator(BeanDeserializer.java:565) ~[jackson-mapper-asl-1.8.2.jar:1.8.2]
    	at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:365) ~[jackson-mapper-asl-1.8.2.jar:1.8.2]
    	at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2395) ~[jackson-mapper-asl-1.8.2.jar:1.8.2]
    	at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1655) ~[jackson-mapper-asl-1.8.2.jar:1.8.2]
    	at org.springframework.http.converter.json.MappingJacksonHttpMessageConverter.readInternal(MappingJacksonHttpMessageConverter.java:136) ~[spring-web-3.1.0.M2.jar:3.1.0.M2]
    	at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:154) ~[spring-web-3.1.0.M2.jar:3.1.0.M2]
    	at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:74) ~[spring-web-3.1.0.M2.jar:3.1.0.M2]
    	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:446) ~[spring-web-3.1.0.M2.jar:3.1.0.M2]

  • #2
    I am able to get details on the account using the ID instead of "me":

    https://graph.facebook.com/me
    Code:
    false
    https://graph.facebook.com/166433633429626
    Code:
    {
       "id": "166433633429626",
       "name": "My Biz",
       "picture": "http://profile.ak.fbcdn.net/static-ak/rsrc.php/v1/y0/r/XsEg9L6Ie5_.jpg",
       "link": "http://www.facebook.com/pages/My-Biz/166433633429626",
       "category": "Arts/entertainment/nightlife",
       "location": {
          "street": "123 Any St",
          "city": "Fredericton",
          "state": "NB",
          "country": "Canada",
          "zip": "E3B1A1"
       },
       "can_post": true
    }
    Unfortunately, that required me knowing the page's ID beforehand.

    Comment


    • #3
      I've posted this in the FB Developer forum (famous for their great support) here: http://forum.developers.facebook.net....php?id=106250

      It seems like a bug on their side, is there any way to get the user's ID during the OAuth process? I thought the accessToken contained it somewhere but it doesn't seem to in this case (could be that it contains the non-existent user profile ID, which is why it's returning "false").

      Since I'm requesting access to the user's pages, I was able to make a call to https://graph.facebook.com/me/accounts, which returned the Fan Page.

      My users are insistent this is a valid use case so I'll have to sort it out somehow, but my suspicion is that Facebook would/will not support it.

      Comment


      • #4
        It looks like the problem is that 166433633429626 is a Page object, not a User object. "me" is an alias for the currently authenticated User. But since 166433633429626 is the ID of a page, "me" can't possibly be an alias for it. It's also annoying that you get "false" back...I'd expect to get some sort of error indicating the alias doesn't exist.

        That said, I understand your issue. If you can login as a page, you should be able to fetch the info for the page in a way consistent with how you'd fetch info for the currently authenticated user. But be aware that even if "me" returned the JSON you show, it would still not work when you call getUserProfile() because you'd be trying to retrieve Page data into a UserProfile object. Actually, since the JSON deserialization is rather loose, it wouldn't fail, but some of the UserProfile fields you may expect won't be populated and some of the Page-specific data will be lost because there's no place to put it in the UserProfile object. What you'd really want to do is call FeedOperations.getPage() to get the Page object.

        I'm not advocating that you parse the token to get the user ID, but every FB access token I've seen has it just before the 2nd pipe ('|') character. But my guess is that whatever ID you see there refers to the same pseudo-user that "me" refers to and will give you "false" just the same. In this case, the only meaningful data is probably behind 166433633429626, which is the fan page itself, not the user.

        Comment


        • #5
          Yes; I'm guessing that FB has created a user behind the scenes, whose ID is before the 2nd pipe character but it will just continue to return false as "me" does. I'll have to use the "me/accounts" as a workaround (ugh).

          Comment


          • #6
            FWIW, PageOperations.getAccounts() does the "me/accounts" call for you giving a List<Account>.

            Comment


            • #7
              Thanks; that's the one that'll be in RC2?

              Comment


              • #8
                Yes...will be there in RC2.

                Comment

                Working...
                X