Facebook正在给我一个错误= access_denied,同时在我的项目中使用facebook oauth 这是我的代码:
var facebookOptions = new FacebookAuthenticationOptions()
{
AppId = "---",
AppSecret = "---",
BackchannelHttpHandler = new FacebookBackChannelHandler(),
UserInformationEndpoint = "https://graph.facebook.com/v2.4/me?fields=id,email"
};
facebookOptions.Scope.Add("email");
app.UseFacebookAuthentication(facebookOptions);
和FacebookBackChannelHandler.js:
namespace naah2.Facebook
{
public class FacebookBackChannelHandler : HttpClientHandler
{
protected override async Task<HttpResponseMessage>
SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken)
{
if (!request.RequestUri.AbsolutePath.Contains("/oauth"))
{
request.RequestUri = new Uri(
request.RequestUri.AbsoluteUri.Replace("?access_token", "&access_token"));
}
return await base.SendAsync(request, cancellationToken);
}
}
}
有人可以帮忙吗?
答案 0 :(得分:0)
您不再需要使用反向通道处理程序。 安装Microsoft.Owin.Security.Facebook-4.0.0版(最新)
在Startup.Auth.cs
中,
app.UseFacebookAuthentication(
appId: "xxxxxxxxxx",
appSecret: "xxxxxxxxxxxxxxxxxxxxxxxxx"
);
就是这样,您不需要其他信息,并删除BackChannelHandler类文件