It turns out that Facebook API v 2.4 has undergone significant changes in which you need to specify the fields that you want to receive. Previously used a graph request:
https:
but for performance reasons, as from FB API v2.4, you also need to specify the files that you want to receive within the scope:
https:
The Microsoft FB client implementation, by default, binds access_token to the query string as "? Access_token", which leads to a broken request (additional question mark):
https://graph.facebook.com/v2.4/me?fields=id,name,email?access_token=XXXXX
So, to fix this, we need to use a custom BackchannelHttpHandler. First, we create an endpoint class:
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); } }
And then we provide it in facebook auth options along with an explicit indication of UserInformationEndpoint:
var facebookAuthOptions = new FacebookAuthenticationOptions { AppId = ConfigurationManager.AppSettings["FacebookAppId"], AppSecret = ConfigurationManager.AppSettings["FacebookAppSecret"], BackchannelHttpHandler = new FacebookBackChannelHandler(), UserInformationEndpoint = "https://graph.facebook.com/v2.4/me?fields=id,name,email", Scope = { "email" } <.....> };
From: fooobar.com/questions/89113 / ...