我正在尝试通过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]
此时我缺少什么?
非常感谢
答案 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