Token Invalid error #445
-
Hello, I am currently trying to use fattureincloud to manage invoices for a client project but I am getting the following error, Error: {"error":"invalid_grant","error_description":"Invalid token."} I tried searching for what the error could mean but since my first language is not italian nor english it is little hard for me to get resources. try {
const oauth = getOauthCodeManager();
const params = oauth.getParamsFromUrl(req.body.url);
const auth_code = params.authorizationCode;
const token = await oauth.fetchToken(auth_code); // error is occuring here
res.json({ token });
} catch (error) {
console.log(error);
res.json({ error: error });
} Can anyone explain me why this error is ocurring? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @alsongarbuja I think the problem could be the auth_code variable's content. Can you please try to print the variable and check if it contains a string starting with "a/"? Thanks |
Beta Was this translation helpful? Give feedback.
Sorry @alsongarbuja my mistake, "c/" is the correct prefix.
If the auth code has the correct value, it should work correctly. From our logs it seems that you're executing the same operation twice, the first one goes to success and returns the token, invalidating the auth code. When you try to perform the same operation again with the same code you obtain 401 error because the code was invalidated at the first attempt.
You should try to check why your code is performing the same operation twice in a short amount of time.
Thanks
Mauro