I have youtube login setup with OAuth2 and upon a successful user registration I would like to save the users gender and location in the database.
Checking the OAuth docs https://developers.google.com/accounts/docs/OAuth2Login#userinfocall
you can see that you can access a users gender and location along with things like name, email and their profile picture.
Below is my code for saving a users info to the db
user.rb
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user.email = auth.info.email
user.picture = auth.info.image
user.gender = auth.info.gender
user.country = auth.info.locale
user.oauth_token = auth.credentials.token
user.oauth_expires_at = Time.at(auth.credentials.expires_at)
user.save!
end
end
but using the auth.info.USER_INFO config doesn’t seem to save these values to the database. Am i missing something?
Here are the parameters my app is asking for without any scopes.

UPDATE
I got this to work by passing in an extra scope for the userinfo.profile parameter. Remember to include full urls with no commas separated by a space.
Rails.application.config.middleware.use OmniAuth::Builder do
provider :youtube, YOUTUBE_KEY, YOUTUBE_SECRET, { :scope => "https://www.googleapis.com/auth/userinfo.profile https://gdata.youtube.com", access_type: 'offline', approval_prompt: '' }
end
This got the following permissions

Can you post the code where you ask for OAuth scopes? My guess is that you aren’t asking for the profile scope. Check out this site:
https://developers.google.com/oauthplayground/
If you’re just using the YouTube sample code, you’re probably not asking for the profile scope:
https://www.googleapis.com/auth/userinfo.profile
You can tell if you are asking for this scope or not when you hit the auth page, because the auth page will say something like:
“Google OAuth 2.0 Playground is requesting permission to:
View basic information about your account
View your name, public profile URL, and photo
View your gender and birthdate
View your country, language, and timezone”
I’ve attached a screenshot.
If you’re not seeing this, look to where you are configuring your scopes and add this to the list of OAUth scopes to authorize.