title: Devise Omniauth + Linkedin Error. "Not found. Authentication passthru"
body: <p>I followed the instructions exactly as in <a href="http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/#changes" rel="noreferrer">http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/#changes</a></p>
  
  <p>To implement Devise Omniauth Linkedin in my app, I did the following,</p>
  
  <p>In devise.rb</p>
  
  <pre><code>config.omniauth :linked_in, "*******", "**********"
  </code></pre>
  
  <p>And in my user model which is <strong>user.rb</strong> , I had this</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    # Include default devise modules. Others available are:
    # :lockable, :confirmable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
       :recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable
  
  TEMP_EMAIL_PREFIX = 'change@me'
  TEMP_EMAIL_REGEX = /\Achange@me/
  validates_format_of :email, :without =&gt; TEMP_EMAIL_REGEX, on: :update
  
  def self.find_for_oauth(auth, signed_in_resource = nil)
  
  # Get the identity and user if they exist
  identity = Identity.find_for_oauth(auth)
  
  # If a signed_in_resource is provided it always overrides the existing user
  # to prevent the identity being locked with accidentally created accounts.
  # Note that this may leave zombie accounts (with no associated identity) which
  # can be cleaned up at a later date.
  user = signed_in_resource ? signed_in_resource : identity.user
  
  # Create the user if needed
  if user.nil?
  
    # Get the existing user by email if the provider gives us a verified email.
    # If no verified email was provided we assign a temporary email and ask the
    # user to verify it on the next step via UsersController.finish_signup
    email_is_verified = auth.info.email &amp;&amp; (auth.info.verified || auth.info.verified_email)
    email = auth.info.email if email_is_verified
    user = User.where(:email =&gt; email).first if email
  
    # Create the user if it's a new registration
    if user.nil?
      user = User.new(
        name: auth.extra.raw_info.name,
        #username: auth.info.nickname || auth.uid,
        email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com",
        password: Devise.friendly_token[0,20]
      )
      user.skip_confirmation!
      user.save!
    end
  end
  
  # Associate the identity with the user if needed
  if identity.user != user
    identity.user = user
    identity.save!
  end
  user
   end
  
   def email_verified?
  self.email &amp;&amp; self.email !~ TEMP_EMAIL_REGEX
  end
  
   end
  </code></pre>
  
  <p>My <strong>routes.db</strong> file looks like this</p>
  
  <pre><code>devise_for :users, :controllers =&gt; { omniauth_callbacks: 'omniauth_callbacks' }
  match '/users/:id/finish_signup' =&gt; 'users#finish_signup', via: [:get, :patch], :as =&gt; :finish_signup
  </code></pre>
  
  <p><strong>controllers/omniauth_callbacks_controller.rb</strong></p>
  
  <pre><code>   class OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
        def self.provides_callback_for(provider)
        class_eval %Q{
        def #{provider}
        @user = User.find_for_oauth(env["omniauth.auth"], current_user)
  
       if @user.persisted?
         sign_in_and_redirect @user, event: :authentication
        set_flash_message(:notice, :success, kind: "#{provider}".capitalize) if is_navigational_format?
      else
        session["devise.#{provider}_data"] = env["omniauth.auth"]
        redirect_to new_user_registration_url
      end
    end
  }
   end
  
  [:linked_in].each do |provider|
  provides_callback_for provider
  end
  
  def after_sign_in_path_for(resource)
  if resource.email_verified?
    super resource
  else
    finish_signup_path(resource)
  end
  end
  def linkedin
  # You need to implement the method below in your model (e.g. app/models/user.rb)
  @user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
  
  if @user.persisted?
    sign_in_and_redirect @user, :event =&gt; :authentication #this will throw if @user is not activated
    set_flash_message(:notice, :success, :kind =&gt; "Facebook") if is_navigational_format?
  else
    session["devise.facebook_data"] = request.env["omniauth.auth"]
    redirect_to new_user_registration_url
  end
  end
  def action_missing(provider)
  # Set up authentication/authorizations here, and distribute tasks
  # that are provider specific to other methods, leaving only tasks
  # that work across all providers in this method. 
  end
  end
  </code></pre>
  
  <p>When I click on the link to sign in with Linkedin the below error appears:</p>
  
  <p>Not found. Authentication passthru.</p>
  
  <p>Please help me.I don't undeerstand what is wrong, tried time and again but same error appears, Thank you!</p>