public override async Task AuthenticateExternalAsync(ExternalAuthenticationContext ctx) { var externalUser = ctx.ExternalIdentity; var message = ctx.SignInMessage; if (externalUser == null) { throw new ArgumentNullException("externalUser"); } var user = await _userManager.FindByLoginAsync(externalUser.Provider, externalUser.ProviderId).ConfigureAwait(false); if (user == null) { ctx.AuthenticateResult = await ProcessNewExternalAccountAsync(externalUser.Provider, externalUser.ProviderId, externalUser.Claims); } else { ctx.AuthenticateResult = await ProcessExistingExternalAccountAsync(user, externalUser.Provider, externalUser.ProviderId, externalUser.Claims); } }