我正在使用Owin开发Asp.Net外部身份和OAuth。身份验证适用于Facebook和Google。适用于Google和Facebook的 OnAuthenticated 也可以使用:
options.Provider = new FacebookAuthenticationProvider
{
OnAuthenticated = context =>
{
// Retrieve the OAuth access token to store for subsequent API calls
string accessToken = context.AccessToken;
// Retrieve the username
string facebookUserName = context.UserName;
return Task.FromResult(true);
},
};
但是在那之后,它重定向:到https://localhost:44300/en/Account/ExternalLoginCallback
但是它不断给出HTTP 500错误。我什至尝试从浏览器打开URL,它给出了相同的错误。之前它工作正常。但是现在,它突然停止工作了。我还尝试通过放置检查点来对其进行调试,但是Controller Action不会触发。
这是身份验证选项:
var options = new FacebookAuthenticationOptions
{
AppId = ConfigurationManager.AppSettings["FACEBOOK_APP_ID"],
AppSecret = ConfigurationManager.AppSettings["FACEBOOK_APP_SECRET"],
CallbackPath = new PathString("/en/Account/ExternalLoginCallback"),
};
PS::如果我删除了 CallbackPath ,它甚至都不会转到/ Account / ExternalLoginCallback。认证后进入首页。
我看过其他类似的主题,但不能解决我的问题。如果有人可以帮助我,我真的很棒。谢谢!