Prova12
Prova12

Reputation: 653

Missing required client identifier - Google Calendar

I am following this tutorial to implement google calendar on my Rails application. https://readysteadycode.com/howto-integrate-google-calendar-with-rails

config/initializer/omiauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :google_oauth2,
           ENV['my_long_key'],
           ENV['my_other_key'],
           { scope: "userinfo.email, calendar" }
end

I generated also config/secrest.yml (It was not present):

  secret_key_base: "i_generated_a_string"
  google_client_id: "my_long_key"
  google_client_secret: "my_other_long_key"

controllers/example_controller.rb

class ExampleController < ApplicationController
  before_action :authenticate_candidate!, except: [:redirect]
  before_action :authenticate_interviewer!, except: [:client_options]


  def redirect
    client = Signet::OAuth2::Client.new(client_options)
    redirect_to client.authorization_uri.to_s
  end

  private

  def client_options
    {
      client_id: ENV["google_client_id"],
      client_secret: ENV["google_client_secret"],
      authorization_uri: "https://accounts.google.com/o/oauth2/auth",
      token_credential_uri: "https://accounts.google.com/o/oauth2/token",
      scope: Google::Apis::CalendarV3::AUTH_CALENDAR,
      redirect_uri: callback_url

    }
  end
end

gems

gem 'google-api-client', require: 'google/apis/calendar_v3'
gem 'omniauth-google-oauth2'
gem 'signet', '~> 0.11.0'

HOWEVER

When I go to: http://localhost:3000/redirect

I get:Missing required client identifier.

Error

Upvotes: 0

Views: 1682

Answers (1)

GProst
GProst

Reputation: 10237

Most likely the env variables with your google credentials aren't passed to the process (i.e. ENV["google_client_id"] and perhaps others too)

Upvotes: 2

Related Questions