Quantcast
Channel: Spring Community Forums - Social
Viewing all articles
Browse latest Browse all 145

Setting the Username for Facebook Logins with Implicit Sign Up

$
0
0
For my project that requires implicit sign-up, I began by implementing login with Twitter. My implementation of the ConnectionSignUp's execute method looked like this:

Code:

public String execute(Connection<?> connection) {
        UserProfile profile = connection.fetchUserProfile();
       
        // This method returns a Twitter screen name, but for Facebook it returns null
        String username = profile.getUsername();
        User user = new User( username, profile.getFirstName(), profile.getLastName(), new DefaultRole() );
        this.userService.create( user );
        return username;
    }

This works fine for Twitter, because the profile.getUsername() returns the Twitter screen name.

Right now I'm trying to add login with Facebook. The problem I'm facing is that the profile.getUsername() method is returning null, which means that the user's record is not inserted into the UserConnection.

I'm looking for a suggestion of my best bet for setting a logical username for a Facebook user.

Viewing all articles
Browse latest Browse all 145

Trending Articles