Version of FoalTS: 4.5.1
Not sure if it is bug, but the 'Unexpected end of JSON input' error message was a bit misleading for me when we had some issues with LinkedIn social API.
It seems reason is that the code first gets the json body before the response.ok is checked.

I'm wondering if having the http status in the TokenError would be a better solution.