Hi @AdamHiatt-6223 , I found out the reason is you used the get
method in the code to make the request, and getting the token needs to be requested using the post
method. Below is my code running axios in my local node environment, and if I change the post
method to the get
method, it does return the content in html format. Hope this helps. Best Wishes.
const APP_ID = '{ clientId }';
const APP_SECERET = '{ clientSecret }';
const TOKEN_ENDPOINT ='https://login.microsoftonline.com/{ tenantid }/oauth2/v2.0/token';
const MS_GRAPH_SCOPE = 'https://graph.microsoft.com/.default';
const axios = require('axios');
const qs = require('qs');
const postData = {
client_id: APP_ID,
scope: MS_GRAPH_SCOPE,
client_secret: APP_SECERET,
grant_type: 'client_credentials'
};
axios.defaults.headers.post['Content-Type'] =
'application/x-www-form-urlencoded';
axios
.post(TOKEN_ENDPOINT, qs.stringify(postData))
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.