String username = fbProfile.username // this is null, see link above, but username cannot be blank or nullable
String firstName = fbProfile.firstName
String lastName = fbProfile.lastName
User person = new User(
username: username,
password: token.accessToken.accessToken,
enabled: true,
accountExpired: false,
accountLocked: false,
passwordExpired: false,
//fill with data loaded from Facebook API
name: [firstName, lastName].join(' '),
email: email
)
person.save(failOnError: true) // if you add failOnError: true then the code will fail here and you see the exception
There is a NPE generated when creating a user as a result of the username field returned by FB being null (link below details this).
http://stackoverflow.com/questions/23957280/no-username-returned-in-facebook-profile/23986618#23986618
FacebookAuthService: