CORS Error when GET access_token by authorization_code
Created at 07 Jun 2020, 18:06
CORS Error when GET access_token by authorization_code
07 Jun 2020, 18:06
Dear all,
I would like to get access_token via OAuth 2.0 by "GET" method from my service but server reject with CORS error. The request URL is correct as docs https://connect.spotware.com/docs/open_api_2/getting_started_v2/open_authentication_v2 with authorization_code.
Bellow is my details:
GET Request:
const headers = {
"Content-Type": "application/json"
};
const host = "localhost:8080";
const redirect_uri = "".concat("http://", host, "/accounts");
const url = "".concat(
"https://connect.spotware.com/apps/token?grant_type=authorization_code&code=",
code,
"&redirect_uri=",
redirect_uri,
"&client_id=",
process.env.VUE_APP_CTRADER_CLIENT_ID,
"&client_secret=",
process.env.VUE_APP_CTRADER_CLIENT_SECRET
);
this.axios
.get(url, { headers: headers })
.then(response => console.log(response))
.catch(e => {
console.log("Error: ", e.response.data);
});
Server Responsed:
.... from origin 'http://localhost:8080' 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.
How can I get access_token or claim my domain?
Regards,
PanagiotisCharalampous
09 Jun 2020, 09:43
Hi uri.fung,
Check this thread in case it is helpful.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous