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
123 stars 159 forks source link

refresh() function is throwing error #173

Closed ravikeshyadav4 closed 5 months ago

ravikeshyadav4 commented 5 months ago

When I'm calling to refresh the access_token by oauthClient.refresh() then it's throwing error. data: { error: 'invalid_grant' } error: 'Request failed with status code 400',

Access_token is getting expire in an hour and every time we need to login to make api calls.

Same thing is happening with refreshUsingToken() function after passing token it's throwing same error.

THe refresh_token is generated by intuit-oauth package is not working in postman also. I have tried to generate tokens from playground and that was generating new token but refresh_token generated by this package is not generating new token using postman also. Error in postman is { "error": "invalid_grant" }

I'm on intuit-oauth: 4.1.2

rajeshgupta723 commented 5 months ago

Hi @ravikeshyadav4 please make sure this is not caused by a double call to the callback which would poison the token you are storing in your database. Basically if you made a second call (immediately by mistake) with the same oauth code to get the token again, this would invalidate the token for that auth code on our side. This happens because the system our side thinks it could be malicious or fraudulent call by the caller. For further details, please feel free to access the developer documentation regarding this: https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/faq#invalid-grant-error