node-quickbooks icon indicating copy to clipboard operation
node-quickbooks copied to clipboard

Don't know if i shall add it to to issues but no documentaion for refreshAccessToken Function

Open skrawani opened this issue 3 years ago • 4 comments

Like the documentation is very poor I didn't it was there or not until I read the package files myself, please update the documentation

skrawani avatar May 06 '21 10:05 skrawani

Were you able to use refreshToken? I was not. I ended up using API approach.

prajyot-tote avatar May 06 '21 14:05 prajyot-tote

Yes, it is there and I was able to use it.

 qbo.refreshAccessToken((err, accessToken) => {
      //callback 
    });
  1. This will set a new access token and refresh token into qbo object
  2. It also provides new accessTokenen in the callback
    Reference - https://github.com/mcohen01/node-quickbooks/blob/master/index.js#:~:text=*/-,QuickBooks.prototype.refreshAccessToken%20%3D%20function(callback)%20%7B,%7D%3B,-/**

skrawani avatar May 06 '21 14:05 skrawani

Thanks man :) Though a documentation would help.

prajyot-tote avatar May 10 '21 05:05 prajyot-tote

Thanks! I'm fairly new to react and oauth in general. I'm struggling with handling the flow of this. So get the qbo via new Quickbooks. Then I attempt to use qbo to get a list of accounts via qbo.findAccounts. I get an error that the token is expired. When do I run the qbo.refreshAccessToken and what do I do with the token once I get it? Do I run it after I get the error response from the findAccounts fails or do I run it before to ensure it's refreshed before attempting to find the accounts? If I run it before what do I do with this? I run the qbo.refreshAccessToken and I get the token back, what do I do with the token so that I can start using the api with the new token? Thanks!

scole954387 avatar Mar 24 '22 12:03 scole954387