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
121 stars 156 forks source link

Can I use this library in a 'Lambda' function with no human interaction ? #62

Closed 29er closed 4 years ago

29er commented 4 years ago

Hi, I thought I could use this lib to handle quickbooks oauth that did not have any hman interaction as far as refreshing tokens etc. But I have tried for two days to get this to work and seem to always get these errors. 'The Refresh token is invalid, please Authorize again.'. and I am stuck on what to do. Am i using the wrong library to accomplish this ? any suggestions ? Thanks!

29er commented 4 years ago

I guess what Im looking for is some example code that will take an existing token ( from my db ), validate it, or refresh if needed, and make an api call. after the api call should I save the token back to db ? which I will then use for the next call ? will the refresh token always work even if my lambda doesn't run for over an hour etc. Thanks for any insight .

hlu2 commented 4 years ago

@29er "after the api call should I save the token back to db ? which I will then use for the next call ?" That is correct. Remember to save the refresh token to your db and access token to you session. "will the refresh token always work even if my lambda doesn't run for over an hour etc." If you continue using the app, then the refresh token is changed every 24 hours. We have an FAQ section for Authentication here: https://help.developer.intuit.com/s/faqs read it and it should help.

The reason you get 'The Refresh token is invalid, please Authorize again.' probably is due to the fact that your refresh token is not valid. Sometimes developer store their refresh token in the session and never update the value of it.