title: LinkedIn Omniauth OAuth 2 in Rails - Authentication failure for bad redirect
body: <p>I am trying to figure out how to configure LinkedIn's authentication with my Rails 4 app, which uses devise and omniauth. I have: gem 'omniauth-linkedin-oauth2' in my gem file.</p>
  
  <p>I have registered my application with LinkedIn and have inserted the secret and key in my app. The LinkedIn developer forum has confirmed that the process is working, but is saying that the redirect path registered does not match what I have in my callback.</p>
  
  <p>I have an omniauth_callbacks controller, which has the following code in it:</p>
  
  <pre><code>def linkedin
      @user = User.find_for_linkedin_oauth(request.env["omniauth.auth"])
        if @user.persisted?
          redirect_to root_path, :event =&gt; :authentication
          # sign_in_and_redirect @user, :event =&gt; :authentication #this will throw if @user is not activated
          #  set_flash_message(:notice, :success, :kind =&gt; "LinkedIn") if is_navigational_format?
          else
            session["devise.linkedin_data"] = request.env["omniauth.auth"]
            redirect_to root_path
          end
        end
  </code></pre>
  
  <p>I am redirecting to my root_path.</p>
  
  <p>My root_path is defined in my routes.rb file as: home#home.</p>
  
  <p>Within my views folder, i have a folder called home, with a file called home.html.erb.</p>
  
  <p>I have registered the redirect URL with LinkedIn as: www.xxxxxxx.com/home and have also tried the following: www.xxxxxxx.com, www.xxxxxxx.com/views/home/home, www.xxxxxxx.com/home/home. None of these paths work.</p>
  
  <p>Please can someone help me to understand how to define a redirect path that is capable of being recognised by LinkedIn as matching my root_path.</p>
  
  <p>Thank you very much in advance.</p>