title: LinkedIn Authentication via Oauth2 returns null result (error=access_denied)
body: <p>I moved my ASP.NET MVC web application from membership to Identity authentication and since that I cannot authenticate on LinkedIn anymore.</p>
  
  <p>The Facebook authentication is still working fine but the LinkedIn is always returning a null loginInfo after the GetExternalLoginInfo call.</p>
  
  <p>For the LinkedIn I'm using the Owin LinkedIn provider: <a href="https://github.com/tanveery/linkedin-net" rel="nofollow" title="LinkedIn APIs for .NET">LinkedIn APIs for .NET</a>. I also unsuccessful tried to follow <a href="http://www.jerriepelser.com/blog/introducing-the-yahoo-linkedin-oauth-security-providers-for-owin" rel="nofollow">this post from Jerrie Pelser</a>.</p>
  
  <p>The Application calls the ExternalLogin Action that executes the ExecuteResult method and calls back the ExternalLoginCallback (after I allow access to the application). As I stated before, the method AuthenticationManager.GetExternalLoginInfoAsync() always returns a null loginInfo.</p>
  
  <p>I checked the application settings in the LinkedIn and everything seems to be OK.</p>
  
  <p>Ops! I almost forgot to say that the LinkedIn is returning back the URL with a generic error message: <em>"GET /Account/ExternalLoginCallback?error=access_denied HTTP/1.1"</em></p>
  
  <p>I can Authenticate using the DotNetOpenAuth.Clients (hosted github) but I'd like to just use the Identity.</p>
  
  <p><strong>Startup.Auth.cs</strong></p>
  
  <pre><code>var linkedInOptions = new LinkedInAuthenticationOptions();
          linkedInOptions.ClientId = "Xxxxx";
          linkedInOptions.ClientSecret = "Yyyyyyy";
  
          linkedInOptions.Scope.Add("r_fullprofile");
  
          linkedInOptions.Provider = new LinkedInAuthenticationProvider()
          {
              OnAuthenticated = async context =&gt;
              {
                  context.Identity.AddClaim(new System.Security.Claims.Claim("LinkedIn_AccessToken", context.AccessToken));
              }
          };
  
          linkedInOptions.SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie;
  
          app.UseLinkedInAuthentication(linkedInOptions);
  </code></pre>
  
  <p><strong>ExternalLogin</strong></p>
  
  <pre><code>public ActionResult ExternalLogin(string provider, string returnUrl)
      {
          // Request a redirect to the external login provider
          return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }));
      }
  </code></pre>
  
  <p><strong>CallBack Action</strong>        </p>
  
  <pre><code>var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
  if (loginInfo == null)
  {
      return RedirectToAction("Login");
  }
  </code></pre>
  
  <p><strong>LinkedIn CallBack URI</strong></p>
  
  <pre><code>http://localhost:3279/signin-linkedin
  </code></pre>