简体   繁体   中英

OAuth::Unauthorized 400 error with Google+ login API

I'm trying to set up Google+ login with Devise and omniauth in an app I'm working on and running into an OAuth::Unauthorized 400 error. I'm using the omniauth-google gem. My Devise config sets up omniauth for Google:

config.omniauth :google, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], scope: 'plus.login'

I'm running the site locally on dev.app.com:3000, and in my app settings in the Google Developers Console I've set the JavaScript origin to be http://dev.app.com:3000 and the redirect URI to be http://dev.app.com:3000/users/auth/google/callback. I've confirmed that my key and secret are correct. What's the problem here?

I am not seeing any problem there, you can get better picture with this tutorial [ https://www.digitalocean.com/community/tutorials/how-to-configure-devise-and-omniauth-for-your-rails-application

or u can try

omniauth-google-oauth2

https://github.com/zquestz/omniauth-google-oauth2

The omniauth-google 1.0 strategy for google is deprecated . That said, nothing appears wrong with your configuration.

You're better of switching to OAuth 2.0 , unless you have a very compelling reason not to. Notice that the provider symbol has changed from :google to :google_oauth2 . After you switch, it should look like:

provider :google_oauth2, ENV["GOOGLE_KEY"], ENV["GOOGLE_SECRET"]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM