" OAuth的::未授权"尝试将Google身份验证与Rails配合使用时出现错误"设计"宝石

时间:2016-01-22 21:24:36

标签: ruby-on-rails oauth devise google-authentication

我正在使用Rails 4.2.5并且我正在尝试通过Google启用身份验证以允许访问我的应用程序。我正在关注https://www.digitalocean.com/community/tutorials/how-to-configure-devise-and-omniauth-for-your-rails-application'>devise教程。我添加了这些宝石

gem 'devise'
gem 'omniauth'
gem 'omniauth-digitalocean'
gem 'omniauth-google'

同样遵循本教程中的其他步骤,包括将google作为OAuth提供程序添加到config / initializers / devise.rb文件中的devise配置中......

    config.omniauth :google, “myclientid”, “myclientsecret”

当我启动并运行我的Rails服务器时,我可以在

看到我的注册页面

http://localhost:3000/users/sign_in

当我点击“使用Google登录”时,指向此网址 - http://localhost:3000/users/auth/google,我收到此错误...

OAuth::Unauthorized
400 Bad Request

Extracted source (around line #216): 

    self.token_request(http_method, uri.path, token, request_options, arguments)
  when (400..499)
    raise OAuth::Unauthorized, response
  else
    response.error!
  end

任何人都知道我忽略了什么?

1 个答案:

答案 0 :(得分:0)

我有同样的问题。

解决方案here为我工作。

从omniauth-google更改为omniauth-google-oauth2