我使用Microsoft的Identity框架来使用外部登录。除Facebook外,所有其他人都在工作。当我使用Facebook时,它让我登录但没有请求许可,并立即将我返回登录页面,未经授权。
回调网址为http://localhost:14613/signin-facebook/
这是我的外部登录验证码(ID和Secret Blanked):
File oldFile=new File("/opt/test/myfolder/myinsidefolder/myfile.jar");
File newFile=new File(oldFile.getParent+"/"+"Test.xml");
try
{
Files.move(oldFile.toPath(),newFile.toPath());
}
catch (IOException ex)
{
System.err.println("File was not renamed!");
}
预期的结果是它会将我重定向到:localhost / Account / ExternalLoginSucceeded
答案 0 :(得分:3)
虽然在更新以下nuget包时解决了,但我也有类似的问题:
Startup.cs代码是:
var facebookOptions = new FacebookAuthenticationOptions()
{
AppId = "xxxxxx",
AppSecret = "xxxxxx",
Scope = { "email" },
Provider = new FacebookAuthenticationProvider()
{
OnAuthenticated = (context) =>
{
context.Identity.AddClaim(new Claim("urn:facebook:accesstoken", context.AccessToken, ClaimValueTypes.String, "Facebook"));
return Task.FromResult(0);
}
}
};
app.UseFacebookAuthentication(facebookOptions);
我的脸谱图api版本是2.8
答案 1 :(得分:0)
首先,你的桅杆有Owin版本:
<强> 3.1.0 强>
与NuGet一起安装
我发现了某种类似的解决方案,我更改了它并更新了其他功能,例如获取Facebook用户喜欢并且工作得很好
以下是代码(粘贴在Startup.Auth中):
var facebookOptions = new FacebookAuthenticationOptions()
{
AppId = "-----copy from your facebook app-----",
AppSecret = "-----copy from your facebook app-----",
Provider = new FacebookAuthenticationProvider
{
OnAuthenticated = context =>
{
context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken));
return Task.FromResult(true);
}
},
//BackchannelHttpHandler = new FacebookBackChannelHandler(),
//UserInformationEndpoint = "https://graph.facebook.com/v2.4/me?fields=id,name,email,first_name,last_name,location"
};
facebookOptions.Scope.Add("email");
//facebookOptions.Scope.Add("user_likes");
app.UseFacebookAuthentication(facebookOptions);