Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration settings for Omniauth to Google in Rails

I am using Omniauth 1.0.1 in my Rails app for authentication. I have "omniauth-google-oauth2" gem for Google provider. But it shows me the error as

`rescue in provider': Could not find matching strategy for :google. You may need to install an additional gem (such as omniauth-google). (LoadError).

I gave "provider :google, 'domain.com', 'secret', :scope => 'https://mail.google.com/mail/feed/atom/'" in my initializers. Could u please tell me what went wrong? Thank u.

like image 670
Rajeswari Avatar asked Dec 08 '11 10:12

Rajeswari


People also ask

How does OmniAuth work in Rails?

OmniAuth is a gem for Rails that lets you use multiple authentication providers alongside the more traditional username/password setup. 'Provider' is the most common term for an authentication partner, but within the OmniAuth universe we refer to providers (e.g., using a GitHub account to log in) as strategies.

What is OmniAuth Google OAuth2?

The Omniauth Google OAuth2 gem will validate the code via a server-side request to Google. If the code is valid, then Google will return an access token and, if this is the first time this user is authenticating against this application, a refresh token. Both of these should be stored on the server.


2 Answers

Try using

:google_oauth2

as your provider.

like image 119
Jeff Steil Avatar answered Oct 05 '22 01:10

Jeff Steil


Since version 1.0, omniauth has taken out the individual strategies into separate gems. For more info, visit omniauth's page, and/or listen to eg this excellent railscast.

like image 29
Marek Příhoda Avatar answered Oct 05 '22 01:10

Marek Příhoda