Devise + Omniauth电话行动passthru登录Facebook [英] Devise + Omniauth call action passthru on login Facebook

查看:144
本文介绍了Devise + Omniauth电话行动passthru登录Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用Omniauth和Devise登录Facebook时,调用 passthru 而不是 facebook 。如何传递 link_to

When I try to login with Facebook using Omniauth and Devise, passthru is called instead of facebook. How do I pass in the link_to:

user_omniauth_authorize_path(:facebook)

我已经修改了很多次代码,并尝试使用此路由:

I've revised the code many times and tried to use this route:

  devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do
    get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
  end

  devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } 

但错误是一样的。我的 users / omniauth_callbacks_controller.rb

But the error is same. I have the action facebook in my users/omniauth_callbacks_controller.rb

推荐答案

我刚刚用同样的问题解决了几个小时,尝试了一切,包括使用github oauth在不同的分支上执行完全相同的过程,这没有任何问题。最后为我工作的是在应用程序令牌和秘密之后改变我在devise.rb中传递给config.omniauth的参数的哈希值。这是名称:'google'。评论它,它的作品:

I just flailed with the exact same problem for hours, trying everything including doing the exact same process on a different branch with github oauth, which worked without a problem. What finally worked for me was changing the hash of arguments I was passing to config.omniauth in devise.rb after the app token and secret. It was name: 'google' that was doing it. Commented it out and it works:

config.omniauth :google_oauth2, 'ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"],
   {
    # name: 'google',
    scope: 'calendar, plus.login plus.me'
  }

ID和密码是否硬编码无效。我没有尝试,但:name 似乎被用作提供者在代码中的其他位置代替的别名: google_oauth2 。取消注释并将其(冗余)更改为 name:google_oauth2 。我相信你已经解决了这个问题,或者是在一年之后移动了,但是希望这将有助于他们。

Whether the id and secret are hard coded in has no effect. I didn't try it, but :name seems like it is used as an alias for the provider to use elsewhere in the code in place of :google_oauth2. Uncommenting it and changing it (redundantly) to name: google_oauth2 works. I'm sure you've either solved it or moved on after a year but I hope this helps someone in the future.

onmiauth-google-oauth2 0.2.5

onmiauth-google-oauth2 0.2.5

devise 3.4.0

devise 3.4.0

rails 4.1.6

rails 4.1.6

这篇关于Devise + Omniauth电话行动passthru登录Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆