Hi,
I am trying to build an application that uses OAUTH to authenticate with Azure AD and have that access the Dynamics CRM. I have followed the instructions here: https://msdn.microsoft.com/en-us/library/gg327838.aspx and registered a new application in Azure AD portal using Add Applications and got a Client-ID and OAUTH login string. I then use the following code to access Dynamics CRM but that fails with the error:
AuthenticationException: {"error_description":"AADSTS90002: Tenant c935dd8d-8b2c-4f9e-9524-cec3818e46f8 not found. This may happen if there are no active subscriptions for the tenant. Check with your subscription administrator.\r\nTrace ID: b7ae4c31-d48b-4c9f-96de-8bfaa99f3d00\r\nCorrelation ID: db65810e-ea55-42e6-bc03-3ea210d02f5a\r\nTimestamp: 2017-09-07 22:35:01Z","error":"invalid_request"}
Based on other forum discussions there is some mention of registering. https://msdn.microsoft.com/en-us/library/mt622431.aspx
But it is not clear to me how this works as I do not see the options mentioned here.
How does one enable this?
The code I tried is:
public AuthenticationResult getAccessTokenFromUserCredentials(String url, String username, String password)
throws Exception {
AuthenticationContext context = null;
AuthenticationResult result = null;
ExecutorService service = null;
try {
service = Executors.newFixedThreadPool(1);
context = new AuthenticationContext(AUTHORITY, false, service);
Future<AuthenticationResult> future = context.acquireToken(url,
CLIENT_ID,
username,
password, null);
result = future.get();
} finally {
service.shutdown();
}
if (result == null) {
throw new ServiceUnavailableException("authentication result was null");
}
return result;
}