Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 401 AuthorizationFailure response #110

Open
lardcanoe opened this issue Apr 7, 2021 · 3 comments · May be fixed by #120
Open

Handle 401 AuthorizationFailure response #110

lardcanoe opened this issue Apr 7, 2021 · 3 comments · May be fixed by #120

Comments

@lardcanoe
Copy link

The AuthResponse.prototype.getJson function in intuit-oauth/src/response/AuthResponse.js needs to handle a 401 error more elegantly. I had to monkey-patch the function to figure out what was going on. The OAuth credentials I had were able to refresh the token, but the subsequent call failed with AuthResponse is not JSON.

URL:

'https://quickbooks.api.intuit.com/v3/company/91303#####/companyinfo/91303######'

Part of response:

  body: '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2021-04-07T06:07:54.701-07:00"><Fault type="AuthorizatonFault"><Error code="120"><Message>Authorization Failure</Message><Detail>AuthorizationFailure: --11014-You do not have access to use QuickBooks Online Plus., statusCode: 401</Detail></Error></Fault></IntuitResponse>',
  status: 401,
  statusText: 'Unauthorized'
}

Some key headers:

'QBO-Version',
'1955.157',
'ErrorCode',
'120',
'ErrorCause',
'AuthorizationFailure: --11014-You do not have access to use QuickBooks Online Plus., statusCode: 401',
'Message',
'Authorization Failure'
@abisalehalliprasan
Copy link
Collaborator

@lardcanoe : The SDK provides all the error details when an exception is thrown
ref: https://github.com/intuit/oauth-jsclient#error-logging

Which provides more information about the error :

  originalMessage: 'Response has an Error',
  error: 'Unauthorized',
  error_description: 'Unauthorized',
  intuit_tid: '1-606dceb5-xxxxxxxxxxxce650'

If I am missing anything, Could you maybe post the exact error you saw so that we could see if any additional details need to be added?

Thanks

@lardcanoe
Copy link
Author

https://github.com/intuit/oauth-jsclient/blob/master/src/response/AuthResponse.js#L106

which is called from

https://github.com/intuit/oauth-jsclient/blob/master/src/OAuthClient.js#L586

AuthResponse.prototype.getJson is throwing plain Error which is bubbling up that doesn't have any of the other fields present.

@abisalehalliprasan
Copy link
Collaborator

Thanks @lardcanoe . I will get this fixed in the next release 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants