question

adla-3677 avatar image
0 Likes"
adla-3677 asked ·

Oauth2 token: INVALID_GRANT Error (express js)

Hi! I am getting an invalid_grant error and while I was searching for possible fixes, I happen to find this forum. **{"error":"invalid_grant","error_description":"the provided authorization grant code is invalid or was issued to another client"}** Here is my javascript code embedded in my redirect link (accepted URL), app.get('/', function(req, res) { var params = req.query axios({ method: 'POST', url: ' https://api.ebay.com/identity/v1/oauth2/token', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json', 'Cache-Control': 'no-cache', 'Authorization': 'Basic XXXXXW5XXWQtXX9naXN0aWMtUFJELTI4XXX0ZTVlOS0zNGQzZmU1XXpQUkQtXXFmXXU1ZTk3YjUxLWE4MGYtNGIzYy0XXXXXXXXXXXX=' }, data: qs.stringify({ 'grant_type': 'authorization_code', 'redirect_uri': 'Xxxxx_Xxxxx-YyyyyYyy-Xxgist-oirla', 'code': 'v^1.1#i^1#f^0#r^1#I^3#p^3#t^...VeMjYw' }) }) .then((response) => { res.json(error.response.data) }) .catch((error) => { res.json(error.response.data) }) }); I am quite lost of what or where I went wrong. If anyone can point it out, it would be a great help! Thank you.
erroroauth2token erroruser tokenauth-tokeninvalid token
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
krich_developersupport avatar image
0 Likes"
krich_developersupport answered ·
It looks like you are trying to get a Application access token using a client credentials grant. Here, the grant type should be "client_credentials". Here are the instructions: https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.