Hi
I have successfully logged into react SPA application using oauth and I am trying to generate a new auth token to make a API call - with an audience and scope different from that used as part of oauth authentication.
Is it possible to include multiple audiences and scopes (as an array) as part of authentication?
My SPA needs to make multiple API calls using different audiences and scopes.
I have tried below code to generate auth token but this throws CORS error.
Kindly advise.
var options = {
method: “POST”,
url: “https://XX/oauth/token”,
headers: {
“content-type”: “application/x-www-form-urlencoded”,
“Access-Control-Allow-Origin”: window.location.origin,
},
data: new URLSearchParams({
grant_type: “client_credentials”,
client_id: “XX”,
client_secret:
“XX”,
audience: “XX”,
}),
};
axios
.request(options)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.error(error);
});