question

sohkha-1747 avatar image
0 Likes"
sohkha-1747 asked

Can't get application token because of no Access-Control-Allow-Origin error

Hello everyone,

I'm running this code

ebayAuthToken.exchangeCodeForAccessToken('PRODUCTION', code).then((data) => {
   console.log(data);}
)
.catch((error) => {
   console.log(error);
});

Screenshot 2021-05-26 at 8.08.31 PM.png

and getting this error

Access to fetch at 'https://api.sandbox.ebay.com/identity/v1/oauth2/token' from origin 'https://mt3.localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Screenshot 2021-05-26 at 8.04.57 PM.png

I'm using https://github.com/eBay/ebay-oauth-nodejs-client plugin.

Any idea how to fix this error. Thank you for your time.

cors
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
sandjwarehouse2 avatar image
0 Likes"
sandjwarehouse2 answered

I think this is because: one, ebay has CORS enabled on this endpoint and two, your client is doing preflight CORS checks. I would try it in production to see if you have the same issue - you never know. Otherwise I think you'll need another way to do these HTTP requests. I would also check that plugins support pages. Not sure how that pluginwould work as is, but maybe I'm missing something. Maybe there's a way to disable preflight with the HTTP framework being used.

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.