I have an Active Directory object in Azure that has a native client application. The application has all the necessary permissions to be accessed by the Service Management API.
In the AD directory, I have 2 users added. One is the account I was logged in as when I created the directory object. This account was added automatically when the directory was created. The other is one that I manually added after creating the directory object.
So, in the example below, Account 2 was the account I was logged in as when creating the directory. Account 1 I added manually.
When I try to retrieve an access token from the oauth2 endpoint with Account 2 credentials, I get the error:
AADSTS50034: To sign into this application the account must be added to the REDACTED directory.
The account is clearly added to the directory, however. Furthermore, when I use the credentials for Account 1, I am able to successfully authenticate. The only things I'm changing in my script are the username and password. The client ID and tenant ID remain the same.
Why am I getting the error above when the account I am using is clearly a user of the directory?
I found the answer in a different thread. If I'm understanding it correctly, it seems like automated sign-in can only be done from an account sourced from Azure Active Directory, and not from a Microsoft account.