3

I params the Google subscription with the gem 'omniauth-google-oauth2' and I config the ui and provider + in the devise.rb I put this code config.omniauth :google_oauth2, ENV["GOOGLE_ID"], ENV["GOOGLE_SECRET"], scope: 'email', info_fields: 'email, first_name,last_name', image_size: 'large'

I enter the code in application.yml and I generate contacts APIs + Google + APIs but when I want to connect it like this : click here : autorisation the error message tells me that "Csrf detected" Please could you tell what's wrong. Your help is appreciated.

I am a little bit lost.

Hussein.
  • 179
  • 2
  • 11

3 Answers3

0

In your callback controller you can add:

skip_before_action :verify_authenticity_token
Martin B.
  • 760
  • 2
  • 8
  • 21
0

I recently got this same error using the omniauth-google-oauth2 gem:

Could not authenticate you from GoogleOauth2 because “Invalid credentials”

The server logs showed this:

OAuth2::Error {"code"=>403, "message"=>"Legacy People API has not been used in project 1070582368186 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=############# then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."

As discussed in this issue I upgraded the gem to the latest version (0.8.0) which fixed it. Here is the commit that performs the workaround.

joshweir
  • 5,427
  • 3
  • 39
  • 59
-1

I was also having the same issue but with my Rails app. So I resolved it by upgrading the omniauth gems by running bundle update devise omniauth omniauth-google-oauth2 in terminal. Original answer: https://stackoverflow.com/a/62572976/15751045