public IActionResult AddExternalLoginWithNonce(
            int userId,
            string externalProvider,
            string nonce,
            string returnUrl
            )
        {
            //TODO validate returnUrl also?
            if (!m_nonceManager.IsNonceKeyValid(nonce, userId, NonceTypeEnum.AddExternalLogin))
            {
                return(Forbid());
            }

            returnUrl = returnUrl ?? GetDefaultRedirectUrlForUser(userId);

            // start challenge and roundtrip the return URL and
            var redirectUrl = Url.Action("LinkLoginCallback", new { ReturnUrl = returnUrl });

            var properties = m_signInManager.ConfigureExternalAuthenticationProperties(
                externalProvider, redirectUrl,
                userId.ToString()
                );

            return(Challenge(properties, externalProvider));
        }
        public IActionResult ExternalLoginWithNonce(string externalProvider, string nonce)
        {
            if (!m_nonceManager.IsNonceKeyValid(nonce, NonceTypeEnum.ExternalLogin))
            {
                return(Forbid());
            }

            var returnUrl = Url.Action("Index", "Home");

            // start challenge and roundtrip the return URL and
            var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl });

            var properties = m_signInManager.ConfigureExternalAuthenticationProperties(externalProvider, redirectUrl);

            properties.SetParameter("returnUrl", returnUrl);

            return(Challenge(properties, externalProvider));
        }