title: AspNet Core Identity GetExternalLoginInfoAsync Always Null
body: <p>I am using a combination of IdentityServer4 and ASP .NET Core Identity to create a federated sign-in page. One of the external providers I am using is Azure Active Directory through the Open ID Connect protocol. I also have integrated EntityFrameworkCore for all of my data storage. </p>
  
  <p>After I scaffolded my initial website with Identity authentication, I add the appropriate services to my <code>Startup.cs</code> file.</p>
  
  <pre><code>services.AddOidcStateDataFormatterCache();
  // Some DI registrations
  services.Configure&lt;CookiePolicyOptions&gt;(options =&gt;
  {
      options.CheckConsentNeeded = context =&gt; true;
      options.MinimumSameSitePolicy = SameSiteMode.None;
  });
  services.AddDbContext&lt;MyDbContext&gt;();
  services.AddMvc().AddRazorPages(options =&gt; /* Some options */);
  services.AddIdentityServer(options =&gt;
      options.Events.RaiseErrorEvents = true;
      options.Events.RaiseFailureEvents = true;
      options.Events.RaiseInformationEvents = true;
      options.Events.RaiseSuccessEvents = true;
  )
  .AddConfigurationStore(options =&gt; /* Set up DbContext */)
  .AddOperationStore(options =&gt; /* Set up DbContext */)
  .AddAspNetIdentity&lt;MyAppUser&gt;();
  services.AddAuthentication().AddOpenIdConnect(options =&gt;
  {
      // Does not bind itself for mysterious reasons
      Configuration.GetSection("OpenIdConect").Bind(options)
  });
  </code></pre>
  
  <p>I decided it would look nicer if I did most of my authentication setup in my <code>appsettings.json</code> file.</p>
  
  <pre><code>{
      "OpenIdConnect": {
          "ClientId": "&lt;my_client_id&gt;",
          "Authority:" "https://login.microsoft.com/&lt;my_tenant_id&gt;",
          "PostLogoutRedirectUri": "http://localhost:5000/MyApp/Account",
          "CallbackPath": "/signin-oidc",
          "ResponseType": "code id_token",
          "Scope": "openid profile email",
          "SignInScheme": "idsrv.external",
          "AutomaticAuthenticate": "false",
          "AutomaticChallenge": "false",
          "RequireHttpsMetadata": "true"
       }
  }
  </code></pre>
  
  <p>Everything runs and my Open ID Connect login provider appears on the login page automatically. Smashing! Upon trying to use that, I am greeted by an error: <code>Error loading external login information.</code> Ends up that on the scaffolded Razor page
  <code>Areas/Identity/Pages/Account/ExternalLogin.cshtml.cs:72</code> there is this bit of code:</p>
  
  <pre><code>var info = await _signInManager.GetExternalLoginInfoAsync();
  if (info == null)
  {
      ErrorMessage = "Error loading external login information.";
      return RedirectToPage("./Login", new { ReturnUrl = returnUrl });
  }
  </code></pre>
  
  <p><code>info</code> always resolved to null. I suspect it is a configuration issue somewhere in my <code>Startup.cs</code>, or some bit of magic that no documentation bothered to mention.</p>