mcohen01 / node-quickbooks

nodejs client for Intuit's Quickbooks API
332 stars 235 forks source link

Release on npm is out of date, does not support OAuth2 #97

Closed mLuby closed 6 years ago

mLuby commented 6 years ago

TL;DR: the version of this lib on npm is out of date with respect this repo's oauth2example and this Intuit blog post. Solution is to release current version of this repo to npm.

Figured out why this doesn't work outside the oauth2example/ directory. Given this minimal example:

var QuickBooks = require('node-quickbooks')
// var QuickBooks = require('../index');

var qbo = new QuickBooks(consumerKey, consumerSecret, token, false, realmId, true, false, 4, '2.0')
qbo.findAccounts((error, data) => error ? console.error(error) : console.log(data.QueryResponse.Account.slice(0, 1)))

Running the script yields the following (incorrect) response (note the AUTHENTICATION error):

{ warnings: null,
  intuitObject: null,
  fault: { error: [ [Object] ], type: 'AUTHENTICATION' },
  report: null,
  queryResponse: null,
  batchItemResponse: [],
  attachableResponse: [],
  syncErrorResponse: null,
  requestId: null,
  time: 1517548714464,
  status: null,
  cdcresponse: [] }

but when we switch the require statement to the commented out one that references the ../index, this is the (correct) response:

[ { Name: 'Accounts Payable (A/P)',
    SubAccount: false,
    FullyQualifiedName: 'Accounts Payable (A/P)',
    Active: true,
    Classification: 'Liability',
    AccountType: 'Accounts Payable',
    AccountSubType: 'AccountsPayable',
    CurrentBalance: -1602.67,
    CurrentBalanceWithSubAccounts: -1602.67,
    CurrencyRef: { value: 'USD', name: 'United States Dollar' },
    domain: 'QBO',
    sparse: false,
    Id: '33',
    SyncToken: '0',
    MetaData: 
     { CreateTime: '2017-12-30T10:12:02-08:00',
       LastUpdatedTime: '2018-01-06T13:10:36-08:00' } } ]

An easy way to tell whether you're using the OAuth2 capable version is to see if it exposes QuickBooks.setOauthVersion. What npm install node-quickbooks installs doesn't have that method.

mLuby commented 6 years ago

Was fixed in v2.0.23