Devise + LinkedIn(OmniAuth)的路线不正确

时间:2014-06-09 06:58:53

标签: ruby-on-rails ruby devise linkedin omniauth

我正在尝试通过LinkedIn实现注册到当前的Devise gem。这些是目前的路线:

devise_for :users, :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret',
                                    :confirmation => 'verification', :unlock => 'unlock', :registration => 'register',
                                    :sign_up => 'signup' }, :controllers => {:omniauth_callbacks => "omniauth_callbacks"}

视图:= link_to "Sign in with Linkedin",user_omniauth_authorize_path(:linkedin) 返回此错误:

No route matches {:controller=>"omniauth_callbacks", :action=>"passthru", :provider=>:linkedin, :format=>nil} missing required keys: [:provider]

我也尝试添加提供商键,例如:= link_to "Sign in with Linkedin",user_omniauth_authorize_path(:provider => 'linkedin')

但后来我得到了:

No route matches {:controller=>"omniauth_callbacks", :action=>"passthru", :provider=>"linkedin"} missing required keys: [:provider]

此时我缺少什么?

非常感谢

1 个答案:

答案 0 :(得分:1)

devise.rb

中添加该行
config.omniauth :linkedin, 'APP_ID', 'APP_SECRET'

Devise将使用linkedin自动添加登录链接。

omniauth_callbacks_controller.rb中添加方法: -

def linkedin
  #code for authorization using linkedin callback credentials
end