-
Notifications
You must be signed in to change notification settings - Fork 165
Closed
Labels
Description
For some of our clients twice a week the refresh token ends with invalid_grant. We contact them and request to re-authenticate to get new access & refresh token. It is annoying that it happened and we don't know how to handle it in the code.
Currently, our flow is:
- A function that interacts with QuickBooks API is called.
- The function loads the OAuth token from our database.
- If the access token is expired, we request a new token using the refresh token
const QuickbooksOauthClient = require("intuit-oauth");
const quickbooksOauthClient = new QuickbooksOauthClient(getOauthConfig());
const response = await quickbooksOauthClient.refreshUsingToken(clientsCredentials.RefreshToken);
- The new token and refresh token are saved in our database.
- The API is called.
But for a few of our clients the refreshUsingToken() method response with invalid_grant. The following is a response for one of our clients with this issue:
{
"url": "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer",
"headers": {
"date": "Thu, 26 May 2022 05:11:00 GMT",
"content-type": "application/json;charset=utf-8",
"content-length": "25",
"connection": "close",
"intuit_tid": "1-628f0be4-19ed5ea63980105102b16b1e",
"x-spanid": "4ed3e0e2-45a2-47bd-bae5-06c8024b8583",
"x-amzn-trace-id": "Root=1-628f0be4-19ed5ea63980105102b16b1e",
"x-content-type-options": "nosniff",
"server": "envoy",
"cache-control": "no-cache, no-store",
"pragma": "no-cache",
"x-envoy-upstream-service-time": "35",
"strict-transport-security": "max-age=31536000"
},
"body": "{\"error\":\"invalid_grant\"}",
"status": 400,
"statusText": "Bad Request"
}
What can we do to handle this issue by code?
codescalar, jackammon, thekennysong, JoeMartin2001 and mzruiz