Hi @Patrick Rote ,
I followed this post and could get the access token successfully,
You need to change the url in AJAX call to: https://cors-anywhere.herokuapp.com/https://login.microsoftonline.com/tenant.onmicrosoft.com/oauth2/v2.0/token
My demo code for you:
$(document).ready(function () {
requestToken();
});
var token;
function requestToken() {
$.ajax({
async: true,
crossDomain: true,
url: "https://cors-anywhere.herokuapp.com/https://login.microsoftonline.com/tenant.onmicrosoft.com/oauth2/v2.0/token", //pass your tenant
method: "POST",
headers: {
"content-type": "application/x-www-form-urlencoded",
},
data: {
grant_type: "client_credentials",
"client_id ": "xxx", //Provide your app id
client_secret: "xxx", //Provide your client secret genereated from your app
"scope ": "https://graph.microsoft.com/.default",
},
success: function (response) {
console.log(response);
token = response.access_token;
console.log(token);
},
error: function (error) {
console.log(JSON.stringify(error));
},
});
}
Test result:
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.