使用OmniAuth登录的ActionController :: RoutingError

时间:2018-04-06 00:54:20

标签: ruby-on-rails devise omniauth omniauth-google-oauth2

我使用omniauth-google-oauth2进行设计+ omniauth设置。当我尝试使用它登录时,它会尝试GET / o / oauth2 / auth并失败。我认为这是omniauth提供的路线,或者实际上应该尝试获取[google URL] / o / oauth2 / auth,但我找不到任何文档。除了我的路由和控制器之外,我的配置与Devise github的指令大致相同。

routes.rb中:

devise_for :users, :controllers => { :omniauth_callbacks => 'users/auth' }

配置/初始化/ devise.rb:

  config.omniauth :google_oauth2, ENV["SSO_GOOGLE_CLIENT_ID"], ENV["SSO_GOOGLE_CLIENT_SECRET"], {
    scope: "email",
  }

Rails服务器日志:

  

开始GET" / users / auth / google_oauth2" for ****:52980 at 2018-04-05 18:30:17 -0500   I,[2018-04-05T18:30:17.678087#6321] INFO - omniauth:(google_oauth2)请求阶段已启动。   已开始GET" / o / oauth2 / auth?access_type = offline& client_id = ****。googleusercontent.com& redirect_uri = http%3A%2F%2F ****%3A3000%2Fusers%2Fauth%2Fgoogle_oauth2% 2Fcallback&安培; RESPONSE_TYPE =代码&安培;范围=电子邮件&安培;状态= ****" for ****:52980 at 2018-04-05 18:30:17 -0500   ActionController :: RoutingError(没有路由匹配[GET]" / o / oauth2 / auth"):   ...

0 个答案:

没有答案