Results 1 to 3 of 3

Thread: SocialAuthentication Token after authenticated with facebook

  1. #1

    Default SocialAuthentication Token after authenticated with facebook

    After forwarded to facebook page to key in username and password, i'm redirected back to SocialAuthenticationProvider. May i know is SocialAuthenticationToken below correct?


    SocialAuthenticationToken.connectionData.displayNa me= null
    SocialAuthenticationToken.connectionData.imagerl= Yes got value
    SocialAuthenticationToken.connectionData.profileUr l= Yes got value
    SocialAuthenticationToken.connectionData.providerI d = Yes got value
    SocialAuthenticationToken.connectionData.providerU serId= Yes got value

    why displayName can be null? when doing request, i requtested scope "email", where can i get it from socialAuthenticationToken ?

  2. #2
    Join Date
    Aug 2004
    Posts
    1,074

    Default

    The display name is set from the Facebook user's "username". Not all FB users have a username, but some do. Mine, for instance, is "habuma" and Mark Zuckerberg's is "zuck". But some people have not bothered setting their username (they can still login with their email address)...in those cases, the displayName (which is set from the username in FacebookAdapter.java) will be null.

    You can't get the email address from the socialAuthenticationToken. The ConnectionData that the token carries is a minimal profile data and the idea is for it to carry some common user data that most/all providers will make available. Since not all providers will make email available (Twitter, for instance, does not expose their user's email address), it's not one of the values captured in the connection data.

    You can, however, use the Facebook API binding (Facebook/FacebookTemplate) to fetch the user's full profile data and from that get the email. Assuming you have an instance of the Facebook interface, it'd be something like this:

    Code:
    FacebookProfile profile = facebook.userOperations().getUserProfile();
    String email = profile.getEmail();
    Craig Walls
    Spring Social Project Lead

  3. #3
    Join Date
    Aug 2004
    Posts
    1,074

    Default

    The display name is set from the Facebook user's "username". Not all FB users have a username, but some do. Mine, for instance, is "habuma" and Mark Zuckerberg's is "zuck". But some people have not bothered setting their username (they can still login with their email address)...in those cases, the displayName (which is set from the username in FacebookAdapter.java) will be null.

    You can't get the email address from the socialAuthenticationToken. The ConnectionData that the token carries is a minimal profile data and the idea is for it to carry some common user data that most/all providers will make available. Since not all providers will make email available (Twitter, for instance, does not expose their user's email address), it's not one of the values captured in the connection data.

    You can, however, use the Facebook API binding (Facebook/FacebookTemplate) to fetch the user's full profile data and from that get the email. Assuming you have an instance of the Facebook interface, it'd be something like this:

    Code:
    FacebookProfile profile = facebook.userOperations().getUserProfile();
    String email = profile.getEmail();
    Craig Walls
    Spring Social Project Lead

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •