title: Devise/Google OAuth 2: Not found. Authentication passthru
body: <p>I followed the tutorial in the readme of the <a href="https://github.com/zquestz/omniauth-google-oauth2" rel="noreferrer">omniauth-google-oauth2</a> gem and when I click the link on my root (@ <code>pages#home</code>), <code>&lt;%= link_to "Sign up with Google", user_google_oauth2_omniauth_authorize_path %&gt;</code>, I get the error:</p>
  
  <blockquote>
    <p>Not found. Authentication passthru.</p>
  </blockquote>
  
  <p>I've confirmed the ENV vars are there. I've been looking at similar topics with no luck. Any idea what I'm doing incorrectly?</p>
  
  <p>In routes:</p>
  
  <pre><code>Rails.application.routes.draw do
        devise_for :users, controllers: { :omniauth_callbacks =&gt; "users/omniauth_callbacks" }
  </code></pre>
  
  <p>My omniauth_callbacks_controller is located at <code>/controllers/users/omniauth_callbacks_controller.rb</code></p>
  
  <pre><code>class Users::OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
    def google_oauth2
        # You need to implement the method below in your model (e.g. app/models/user.rb)
        @user = User.from_omniauth(request.env["omniauth.auth"])
  
        if @user.persisted?
          flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind =&gt; "Google"
          sign_in_and_redirect @user, :event =&gt; :authentication
        else
          session["devise.google_data"] = request.env["omniauth.auth"].except(:extra) #Removing extra as it can overflow some session stores
          redirect_to new_user_registration_url, alert: @user.errors.full_messages.join("\n")
        end
    end
  end
  </code></pre>
  
  <p>In my <code>devise.rb</code> file:</p>
  
  <pre><code>config.omniauth :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"], {
        name: 'my-project',
        scope: 'email',
        prompt: 'select_account',
        image_aspect_ratio: 'original',
        image_size: 100,
        ssl_verify: false
    }
  </code></pre>
  
  <p>And in my User.rb:</p>
  
  <pre><code>devise :rememberable, :validatable, :omniauthable, :omniauth_providers =&gt; [:google_oauth2]
  
     def self.from_omniauth(access_token)
           data = access_token.info
           user = User.where(:email =&gt; data["email"]).first
  
           # Uncomment the section below if you want users to be created if they don't exist
           # unless user
           #     user = User.create(name: data["name"],
           #        email: data["email"],
           #        password: Devise.friendly_token[0,20]
           #     )
           # end
  
           user
       end
  </code></pre>