jenisats | 2023-02-22 13:55:59 UTC | #1
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("granttype", "clientcredentials");
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));
tim.smith | 2023-02-22 14:50:01 UTC | #2
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.
system | 2023-03-25 14:50:21 UTC | #3
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 18527