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
119 stars 153 forks source link

Revoke throws an error when trying to process the response #170

Open Matthew-John-Emerson opened 3 months ago

Matthew-John-Emerson commented 3 months ago

When I call revoke, I end up getting an error because it is trying to destructure the response JSON when the json is null. This happens even though the request to Intuit succeeds and the token is revoked. Also, it looks like the tests for revoke are also failing locally.

bogeorget4 commented 3 months ago

I'm seeing this as well. The error I get is "TypeError: Cannot destructure property 'request' of '(intermediate value)(intermediate value)(intermediate value)' as it is null."

It says it's occurring here https://github.com/intuit/oauth-jsclient/blob/master/src/OAuthClient.js#L319

rajeshgupta723 commented 3 months ago

Thanks @Matthew-John-Emerson and @bogeorget4 , could you please help with the steps to reproduce this error.

crisebrough commented 3 months ago

I run into this as well. I am able to see it when I connect to QBO, and then disconnect through the use of OAuthClient.revoke(); which responds with status 200 but there is no body on the JSON response. Thus, the disconnect is successful but it throws an error.

stepanFederlian commented 3 months ago

Hi, @rajeshgupta723 I have the same problem, I use intuit-oauth: 4.1.2.

vektorblake commented 3 months ago

I too am encountering this issue, on a DELETE request. 4.1.2

rajeshgupta723 commented 2 months ago

Hi, thank you all, will look into this. In the meantime, feel free to raise a PR for the fix.

amadeogallardo commented 2 months ago

This is what is logged when using the revoke function:

image

rajeshgupta723 commented 1 month ago

Hi @amadeogallardo @vektorblake @stepanFederlian @Matthew-John-Emerson @crisebrough @bogeorget4 -- could you all please get the latest from the branch release-4.1.3 and test this out. Please confirm if the fix works for you. Thanks

m4xleb commented 1 month ago

Hi @rajeshgupta723 , I did try the release-4.1.3 and still got an issue.

The res returns an empty body and a null json. It seems like the validation of the json is to make sure we get a valid response from the server.

I have attached a screen shot.

image

I have changed line 319 from

const authResponse = res.json ? res : null;

to

const authResponse = res.hasOwnProperty('json') ? res : null;

and the error ran away.