the provided authorization grant code is invalid or was issued to another client
alejandro123210 opened this issue · 3 comments
"ebay-api": "^7.0.2",
"express": "^4.18.1"
So I've been trying to get Oauth2 to work lately, and while I'm able to get the user to navigate to the consent form, accept, login, and get ebay to hit the success URL, I can't seem to get the actual access token. I tried copying the exact code from the example like this:
app.get("/success", async (req, res) => {
// 3. Get the parameter code that is placed as query parameter in redirected page
const code = req.query.code; // this is provided from eBay
const eBay = eBayApi.fromEnv(); // or use new eBayApi()
try {
const token = await eBay.OAuth2.getToken(code);
eBay.OAuth2.setCredentials(token);
// store this token e.g. to a session
req.session.token = token;
// 5. Start using the API
const orders = await eBay.sell.fulfillment.getOrders();
res.send(orders);
} catch (e) {
console.error(e);
res.sendStatus(400);
}
});
but on attempting to run EBay.OAuth2.getToken(code) I get the following error:
'the provided authorization grant code is invalid or was issued to another client'
After looking into the issue online, some people run into an issue with the encoding of the code, but that doesn't seem to be the case here as I'm getting a properly formatted code back and putting that into the function. This has been killing me for days, someone pls help!
If the token is properly encoded, can you can check:
- Mismatch of the prod/Sandbox env.
- Multiple calls on the same code. Add some debug message and make sure the function is only called once.
If the token is properly encoded, can you can check:
- Mismatch of the prod/Sandbox env.
- Multiple calls on the same code. Add some debug message and make sure the function is only called once.
Yep, I made sure everything is only in sandbox as well as the function only being called once, I also don't even have a prod env up and running yet.
no idea what changed, I literally did not change any of the code, but it's working now. Thanks!