I believe this issue has been discussed several times, but I cannot find the solution to my problem. I am using vue js and trying to get access token using the following post request:
let params ={
client_id : this.twitchClientId,
client_secret : this.twitchClientSecret,
grant_type : "client_credentials"
};
axios.post('https://id.twitch.tv/oauth2/token', params, {
headers: {
Accept: 'application/vnd.twitchtv.v5+json'
}
}).then(async res =>{
console.log("Token generated => " + res.data.access_token);
this.twitchAccessToken = res.data.access_token;
}).catch(err => {
console.log("Twitch token err =>");
console.log(err);
});
This is the error I get:
Access to XMLHttpRequest at 'https://id.twitch.tv/oauth2/token' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field client-id is not allowed by Access-Control-Allow-Headers in preflight response.
How can I tackle this issue? Thanks in advance.