Ouath/token api gives CORS error

When I try to access the below API, I am getting the response token in postman.
https://{{dev}}/oauth/token

Whereas in my angular web application (http://localhost:4200) API call is returning the status code as 200 but I am getting CORS error and I did not get any response.

Even I tried using plain javascript and tried calling the API, I am still getting the same CORS error.

Can anyone please help me to resolve this.

Attaching the javascript code below for your reference. .

var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=");
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");

var urlencoded = new URLSearchParams();
urlencoded.append("grant_type", "client_credentials");

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};

fetch("https://xxx.xxxx.pure.cloud/oauth/token", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Basic auth is not supported. Please use one of the supported OAuth grants here: https://developer.genesys.cloud/authorization/platform-auth/. For a client-side web app, you should use the implicit grant. The JavaScript SDK has authorization helpers to handle the flow for you.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.