I'm using omniauth exclusively to allow login to my website with facebook/google/twitter.
I store first name, last name, and email. However, when I raise the twitter auth hash from oauth I only get nickname, name, location, image, description and urls in the auth hash.
Is there a scope I can pass in my initializer to get the user's email and break name out into the first_name, last_name fields?
Twitter does not give out user emails so you will not be able to get that information from the Twitter API. Instead, you have to ask the user to type in their email address on your sign up form.
As far as splitting the name up, you'd do that once you have the hash returned using something like:
social_params ||= request.env["omniauth.auth"]
fullname = social_params["user_info"]["name"].split(' ')
first_name, last_name = fullname[0], fullname[1]
puts "first name is #{first_name} and last name is #{last_name}"
Just keep in mind that last_name
could be nil
if they don't have a space in their name or they didn't give a last name. This also doesn't consider the fact that many people have multiple last names in other cultures.