WebAPI Azure AD使用GetOwinContext()。Authentication.Challenge进行身份验证。不重定向到登录

时间:2019-07-10 18:19:29

标签: azure-active-directory owin

我正在学习OWIN对用户进行身份验证并重定向到一个天蓝色的广告登录页面。我一直在跟踪一个教程,该教程全部使用MVC Web的代码,但我想将代码放在WebAPI中,以便任何客户端都可以重复使用。当我运行代码并输入方法并调用以下代码时,它什么都不做。不会重定向到任何地方。

    [HttpPost]
    [Route("login")]
    public void SignInUser()
    {

            HttpContext.Current.GetOwinContext().Authentication.Challenge(
                new AuthenticationProperties {  RedirectUri = "//azure.portal.com" }, OpenIdConnectAuthenticationDefaults.AuthenticationType
                );

    }

在他的教程中,他使用以下代码,它将用户重定向到蔚蓝的天空

HttpContext.Current.GetOwinContext()。Authentication.Challenge(                     新的AuthenticationProperties {RedirectUri =“ /”},OpenIdConnectAuthenticationDefaults.AuthenticationType                     );

重定向用户时,我在他的教程中看到,URL类似于

https://login.microsoftonline.com/tenantId/oauth2/authroize?client_id= ...

感谢您的帮助。

谢谢

0 个答案:

没有答案
相关问题