title: Google authentication error: invalid_request Missing required parameter: client_id
body: <p>I'm trying to make google authentication using <strong>omniauth-google-oauth2</strong> gem in my project and I've stumbled upon the following error when following the link <strong>localhost:3000/auth/google_oauth2/</strong>.</p>
  
  <p><a href="https://i.stack.imgur.com/PgHqr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PgHqr.png" alt="enter image description here"></a></p>
  
  <p>Why is that?</p>
  
  <p><strong>config/initializers/omniauth.rb</strong></p>
  
  <pre><code>Rails.application.config.middleware.use OmniAuth::Builder do
    provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"]
  end
  </code></pre>
  
  <p><strong>config/routes.rb</strong></p>
  
  <pre><code>Rails.application.routes.draw do
    get '/auth/:provider/callback', to: 'sessions#create'
  
    root to: 'welcome#index'
  end
  </code></pre>
  
  <p><strong>config/secrets.yml</strong></p>
  
  <pre><code>development:
    secret_key_base: here_goes_my_secret_key_base
    google_client_id: 283155193283-8hnfdph0n4089iql70dh8g7428d258qc.apps.googleusercontent.com
    google_client_secret: xHnbKtackWe4D_1mrWTbRS9f
  
  test:
    secret_key_base: here_goes_my_secret_key_base
  
  production:
    secret_key_base: &lt;%= ENV["SECRET_KEY_BASE"] %&gt;
    google_client_id: &lt;%= ENV["GOOGLE_CLIENT_ID"] %&gt;
    google_client_secret: &lt;%= ENV["GOOGLE_CLIENT_SECRET"] %&gt;
  </code></pre>