user984621
user984621

Reputation: 48521

Incorrect routes for Devise + LinkedIn (OmniAuth)

I am trying to implement sign up through LinkedIn to the current Devise gem. These are the current routes:

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"}

And the view: = link_to "Sign in with Linkedin",user_omniauth_authorize_path(:linkedin) Returns to this error:

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

I've tried to add provider key too, like: = link_to "Sign in with Linkedin",user_omniauth_authorize_path(:provider => 'linkedin')

But then I got:

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

What am I missing at this point?

Thank you very much

Upvotes: 0

Views: 388

Answers (1)

Shamsul Haque
Shamsul Haque

Reputation: 2451

Add the line in devise.rb

config.omniauth :linkedin, 'APP_ID', 'APP_SECRET'

Devise will automatically add a signin link using linkedin.

In omniauth_callbacks_controller.rb add a method as:-

def linkedin
  #code for authorization using linkedin callback credentials
end

Upvotes: 1

Related Questions