'Could not authenticate you from GoogleOauth2 because "Invalid credentials"
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 :
the error message tells me that
Please could you tell what's wrong. Your help is appreciated.
I am a little bit lost.
Solution 1:[1]
In your callback controller you can add:
skip_before_action :verify_authenticity_token
Solution 2:[2]
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.
Solution 3:[3]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Martin B. |
| Solution 2 | joshweir |
| Solution 3 | Average |
