I am using the adal4j Java library to authenticate Azure DevOps REST API calls through Azure Active Directory. I am able to authenticate using Personal Access Tokens but not using Active directory. This is the code I have been running:
AuthenticationResult result = null;
ExecutorService service = null;
try {
service = Executors.newFixedThreadPool(1);
AuthenticationContext context = new AuthenticationContext("https://login.microsoftonline.com/" + tenantId + "/", false, service);
if (clientId != null && clientKey != null) {
ClientCredential credentials = new ClientCredential(clientId, clientKey);
Future<AuthenticationResult> future = context.acquireToken("499b84ac-1321-427f-aa17-267ca6975798", credentials, null);
result = future.get();
}
} finally {
if (service != null) {
service.shutdown();
}
}
I get the following error:
StatusCode: 203, ReasonPhrase: 'Non-Authoritative Information'
It tries to redirect to this sign-in page:
https://spsprodsin1.vssps.visualstudio.com/_signin?realm=...
I have already connected to Azure Active Directory from the Azure DevOps organization setting with the correct directory/tenant. And I have also added Azure DevOps user_impersonation permissions (delegated) in the app registration.
What I am doing wrong here and how can I fix the problem?