Hi,
I am trying to generate an access token using Microsoft Graph for which I have registered an app on portal.azure.com .I'm able to generate access token from Postman but getting "No 'Access-Control-Allow-Origin' header is present on the requested resource." and a 400 Bad Request when trying to generate it from browser using jquery.
Scenario: I'm using Power Pages and I want to list items from a SharePoint list for which I need access token from Microsoft Graph, so I can use the access token to perform CRUD operations.
var form = new FormData();
form.append("grant_type", "client_credentials");
form.append("client_id", "{{ClientID}}");
form.append("client_secret", "{{ClientSecret}}");
form.append("scope", "https://graph.microsoft.com/.default");
var settings = {
"url": "https://login.microsoftonline.com/{{TenantID}}/oauth2/v2.0/token",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});
I've searched a lot but unable to find a solution