A cloud-based identity and access management service for securing user authentication and resource access
Thanks so much for the help! Silly mistake on my part.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to get a bearer token from the https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token endpoint. This works fine in postman, but when I try to run it from my node js app, it returns the Sign In html page instead of the bearer token. See code below for implementation:
const tokenUrl = 'https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token';
const clientId = '<id>';
const clientSecret = '<secret>';
const form = FormData();
form.append('client_id', clientId);
form.append('scope', 'https://graph.microsoft.com/.default');
form.append('client_secret',clientSecret);
form.append('grant_type', 'client_credentials');
const getToken = () => {
axios.get(tokenUrl, form, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Host': 'login.microsoftonline.com',
}
}).then((response) => {
return response.data.token;
}).catch(e => console.log(e));
}
I'm sure I am missing something simple, but I am new to Graph API, thanks in advance for the help.
A cloud-based identity and access management service for securing user authentication and resource access
An API that connects multiple Microsoft services, enabling data access and automation across platforms
Thanks so much for the help! Silly mistake on my part.
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more