Forum Discussion

BhararthJanjanam's avatar
BhararthJanjanam
Copper Contributor
May 13, 2022

CORS error while integrating the Azure AD with jQuery

We are using simple jQuery to get the access token from Azure AD. But we are facing the CORS error we are not understanding what we are doing wrong.

Here is the code:

$.ajax({
type: "POST",
URL: "https://login.microsoftonline.com/xxxx-xxxx-xxxx-xxxx/oauth2/token%22,
headers: {
"Content-Type": "application/x-www-form-URL encoded; charset=utf-8",
"Access-Control-Allow-Origin": "*"
},
crossDomain: true,
data: {
"client_id": "xxxx-xxxx-xxxx-xxxx",
"resource": "https://xxxxx.crm.dynamics.com",
"client_secret": "client secret",
"grant-type": "client credentials"
},
success: function (data, textStatus, xhr) {
var results = data;
},
error: function (jqXHR, exception) {
var msg = jqXHR.status;
}
});

 

No RepliesBe the first to reply

Resources