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:
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.
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;
}
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.