【发布时间】:2015-10-28 11:36:07
【问题描述】:
我在使用普通 MVC 5 站点的开箱即用 Microsoft 身份验证时遇到了一些问题。
我已将我的 hosts 文件设置为将 127.0.0.1 路由到 www.mysite.com。
我已将 Windows Live 上的应用程序的重定向 URL 配置为转到 www.mysite.com/signin-microsoft
在 Visual Studio 2015 中,我已将网站的属性设置为使用本地 IIS 和 www.mysite.com
当我尝试通过 Microsoft 进行身份验证时,它会显示实时登录屏幕,当我输入我的详细信息时,它会重定向回帐户控制器端点 ExternalLoginCallback(string returnUrl) 但是 - returnUrl 为空,它尝试获取 loginInfo 的下一行总是返回空。
Auth 在 Startup.Auth 中设置 作为
var options = new MicrosoftAccountAuthenticationOptions
{
ClientId = "<redacted>",
ClientSecret = "<redacted>",
CallbackPath = new PathString("/signin-microsoft")
};
options.Scope.Add(scope);
app.UseMicrosoftAccountAuthentication(options);
我在提琴手中点击了这个网址 - “Account/ExternalLoginCallback?error=access_denied”
我已经关注了这篇文章中的答案 - ASP.NET MVC Microsoft Live Account Authentication on Localhost
我无法弄清楚我错过了什么。
任何帮助将不胜感激。
谢谢
【问题讨论】:
-
什么是“微软认证”?回调站点是否需要可公开访问才能使第三方身份验证正常工作?
-
OAuth 使用 Microsoft 作为提供者。基本上使用 Startup.Auth.cs 中的“UseMicrosoftAccountAuthentication”部分。根据我的阅读,您可以使用主机文件在 dev 中欺骗它...
-
您是否检查过您的回调地址是否已在您的 Microsoft 应用程序中配置?
-
是的 - redirectUrl 设置为 www.mysite.com/signin-microsoft
-
尝试禁用 Restrict JWT Issuing 选项。
标签: c# asp.net-mvc authentication oauth-2.0 asp.net-authentication