oauth-jsclient icon indicating copy to clipboard operation
oauth-jsclient copied to clipboard

`.getJSON` method invoked on xml throws sdk error, masking the original problem

Open railz-guli opened this issue 4 years ago • 3 comments

We're using nodeJs sdk, version 3.0.2 and for certain requests we make with makeApiCall the error we're getting is Error: AuthResponse is not JSON at AuthResponse.getJson (/var/app/current/node_modules/intuit-oauth/src/response/AuthResponse.js:106:29) at OAuthClient.createError

After investigating the error it came to our attention that the sdk is getting back an xml instead of JSON. Moreover, the way sdk handles/throws/logs the error masks the original error we're getting in the xml (we want to see the issues in production). For the short term, if you could add logs before calling .getJSON on the response it would be very helpful.

Thank you!

railz-guli avatar Jun 14 '21 18:06 railz-guli

I'm having this same issue, whenever I attempt to make a request with makeApiCall I'm receiving the error Error: AuthResponse is not JSON at AuthResponse.getJson (~\node_modules\intuit-oauth\src\response\AuthResponse.js:106:29)

I'm receiving this error after using the code example from app.js. I believe my authorization flow is correct so I don't know where to go from here.

aiden5221 avatar Jul 16 '21 18:07 aiden5221

I can also confirm this. We tried setting the headers in makeApiCall but it had no effect:

      await oAuthClient.makeApiCall({
        url,
        method: "GET",
        headers: {
          Accept: "application/json",
          "Content-Type": "application/json",
        },
      })

the response is still coming back as XML:

<?xml version="1.0" encoding="UTF-8"?>
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2021-07-19T22:39:33.743-07:00">
   <Fault type="AuthenticationFault">
      <Error code="100">
         <Message>General Authentication Error</Message>
         <Detail>AuthenticationErrorGeneral: SRV-110-Authentication Failure , statusCode: 401</Detail>
      </Error>
   </Fault>
</IntuitResponse>

akoskm avatar Jul 20 '21 05:07 akoskm

Hi @abisalehalliprasan , This issue requires an urgent fix. I can't get what is the API response. Even if I set the Accept header to 'application/json', the API returns in xml format. also, this issue only occurs when the API responds with an error.

syJSdev avatar Feb 17 '22 13:02 syJSdev