title: Bypass sign In through external authentication using .NET Core Identity
body: <p>Now ExternalLogin.cshtml.cs has 3 methods -</p>
  <ol>
  <li>To open the 3rd party authentication URL</li>
  <li>Get after 3rd party authenticating</li>
  <li>Post after 3rd party authentication</li>
  </ol>
  <p>I am trying to stitch 2 and 3 as I don't want to specifically register the users, but create their account as soon as they login through 3rd party. So this is how I configured OnGetCallbackAsync -</p>
  <pre><code>public async Task&lt;IActionResult&gt; OnGetCallbackAsync(string returnUrl = null, string remoteError = null)
      {
          returnUrl = returnUrl ?? Url.Content(&quot;~/&quot;);
          if (remoteError != null)
          {
              ErrorMessage = $&quot;Error from external provider: {remoteError}&quot;;
              return RedirectToPage(&quot;./Login&quot;, new {ReturnUrl = returnUrl });
          }
          var info = await _signInManager.GetExternalLoginInfoAsync();
          if (info == null)
          {
              ErrorMessage = &quot;Error loading external login information.&quot;;
              return RedirectToPage(&quot;./Login&quot;, new { ReturnUrl = returnUrl });
          }
  
          // Sign in the user with this external login provider if the user already has a login.
          var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false, bypassTwoFactor : true);
          if (result.Succeeded)
          {
              _logger.LogInformation(&quot;{Name} logged in with {LoginProvider} provider.&quot;, info.Principal.Identity.Name, info.LoginProvider);
              return LocalRedirect(returnUrl);
          }
          if (result.IsLockedOut)
          {
              return RedirectToPage(&quot;./Lockout&quot;);
          }
          else
          {
              // If the user does not have an account, then ask the user to create an account.
              ReturnUrl = returnUrl;
              ProviderDisplayName = info.ProviderDisplayName;
              if (info.Principal.HasClaim(c =&gt; c.Type == ClaimTypes.Email))
              {
                  
                  Input = new InputModel { 
                  
  
                      Email = info.Principal.FindFirstValue(ClaimTypes.Email),
                      FirstName = info.Principal.Claims.Where(c=&gt;c.Type==ClaimTypes.GivenName).FirstOrDefault().Value.ToString(),
                      LastName = info.Principal.Claims.Where(c =&gt; c.Type == ClaimTypes.Surname).FirstOrDefault().Value.ToString()
                  };
                  var user = new IdentityUser { UserName = Input.Email, Email = Input.Email };
  
                  var signInResult = await _userManager.CreateAsync(user);
                  if (signInResult.Succeeded)
                  {
                      signInResult = await _userManager.AddLoginAsync(user, info);
                      if(signInResult.Succeeded)
                          await _signInManager.SignInAsync(user, isPersistent: false, info.LoginProvider);
                  }
                  if(signInResult.Errors.Where(c=&gt;c.Code== &quot;DuplicateUserName&quot;).Count() &gt; 0)
                  {
                      await _signInManager.SignInAsync(user, isPersistent: false, info.LoginProvider);
                      
                  }
                  
              }
              return Page();
          }
  </code></pre>
  <p>Now even if I am making the user sign in, its still not reflecting in LoginPartial and LoginPartial checks signIn status with claims. I request to know what am I missing</p>