Auth0 Home Blog Docs

Oauth/token api not working if realm is Azure AD connection



running this code will return error:
{ error: ‘invalid_grant’,
error_description: ‘Invalid username or password’ }


var request = require(“request”);

var option = {
method: ‘POST’,
url: ‘’,
headers: {
‘content-type’: content_type
body: {
grant_type: ‘’,
realm: ‘test-waad’,
username: username,
password: password,
audience: audience,
scope: scope,
client_id: client_id,
client_secret: client_secret
json: true

request(options.resourceOwner, function (error, response, body) {
if (error) throw new Error(error);


My application is setup with Azure AD connection.
I want to use API to return the ID Token and Access Token.
If I am using On-Prem AD, it works. Once I switch to AAD, it gives me error of “Invalid username or password”.
But I confirm that username and password are all correct.

Am I doing anything wrong? Is it the right API endpoint?
Please help.