intuit / oauth-jsclient

Intuit's NodeJS OAuth client provides a set of methods to make it easier to work with OAuth2.0 and Open ID
https://developer.intuit.com/
Apache License 2.0
120 stars 154 forks source link

Check for JSON before parsing JSON in errors #120

Open JimPatterson opened 2 years ago

JimPatterson commented 2 years ago

The createError function was incorrectly assuming that response bodies are in JSON format and attempting to extract useful details from that body. But, for some error cases, the body is not JSON resulting in a error being thrown during the process of adding details to the error.

This fix adds safeguards around the places that need JSON to enable the createError method to extract the useful details.

This likely fixes #110 and fixes #118.