Request.env ['omniauth.auth'] is always nil when using a separate administrator login using the omniauth-identity gem

I want to use a separate admin login for my application using the idenity provider.

I wrote this in config / initializers / omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do provider :identity, :model => Credential, :on_failed_registration =>SessionsController.action(:register) provider :identity, :model => Credential, :name => 'admin', :on_failed_registration => SessionsController.action(:login_admin) provider :google_oauth2, '000000000.apps.googleusercontent.com', '00000000000' end 

In config / routes.rb

  match '/auth/admin/callback', :to => 'sessions#authenticate_admin' 

In application / controllers / session_controller.rb

 def authenticate_admin auth_hash = request.env['omniauth.auth'] session[:admin_user] = auth_hash['user_info']['email'] if admin? redirect_to '/' else render :text => '401 Unauthorized', :status => 401 end end 

But when I try to access request.env ['omniauth.auth'], it always gets zero. Although it is available when using the default callback for regular users in the sessison # create action. I just want to know if there is something that was missing in this code. I follow this blog http://www.intridea.com/blog/2011/1/31/easy-rails-admin-login-with-google-apps-and-omniauth .

+4
source share

All Articles