zquestz / omniauth-google-oauth2

Oauth2 strategy for Google
1.47k stars 414 forks source link

How to access group information #446

Closed shrikanthnext closed 6 months ago

shrikanthnext commented 1 year ago
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :google_oauth2, 'CLIENT_ID', 'CLIENT_SECRET',
    scope: 'email, https://www.googleapis.com/auth/admin.directory.group.readonly'
end
class SessionsController < ApplicationController
  def create
    auth = request.env['omniauth.auth']
    groups = auth.extra.raw_info.groups
    # Process the groups data as needed
    # ...
  end
end

My config looks above. when I inspect groups, its coming as nil. can you please advise.

shrikanthnext commented 1 year ago

@dpickett @will @mkdynamic @yury Anyone available to help with this query?

zquestz commented 1 year ago

This is just the raw data coming back from Google. We don't filter it. Not sure what the cause is.

zquestz commented 6 months ago

Adding a scope just makes sure your token can read the data, not that it will be included! You will need to make another call to access the group data.