OWIN Facebook login throws JsonReaderException

32 views Asked by At

I'm using the good old OWIN Facebook login for years now in an old .Net 4.8 MVC website. Since a few weeks it doesn't work anymore. The Google one is working fine.

I enabled Katana logging and it turns out that this second line in the OWIN implementation throws an error:

string text = await tokenResponse.Content.ReadAsStringAsync();
JObject response = JObject.Parse(text);

Error:

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: a. Path '', line 0, position 0.
    at Newtonsoft.Json.JsonTextReader.ParseValue()
    at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
    at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
    at Microsoft.Owin.Security.Facebook.FacebookAuthenticationHandler.<AuthenticateCoreAsync>d__4.MoveNext()
      in /_/src/Microsoft.Owin.Security.Facebook/FacebookAuthenticationHandler.cs:line 90

By using Fiddler the response from https://graph.facebook.com/v10.0/oauth/access_token looks like valid JSON that ís parsed by Fiddler. I have the latest package versions for Newtonsoft 13.0.3 and Microsoft.Owin 4.2.2 and I don't think the last one will be updated soon ;-).

Any idea what can cause this error while reading a string? And how could I solve this without having to replace this login with custom code?

1

There are 1 answers

0
kloarubeek On

Weird, but by removing my custom FacebookBackChannelHandler (that came from ASP.NET MVC5 OWIN Facebook authentication suddenly not working) the login works again :-)