Hi all,
i'm working on a VM one box 8.1 downloaded from LCS. The url of the machine is like usnconeboxax1aosxxxxxx.cloud.onebox.dynamics.com
My aim is to create an application c# for create and select data with OData.
I'm using DLL libraries provided by https://github.com/Microsoft/Dynamics-AX-Integration/tree/master/ServiceSamples
I created this main method for authenticating:
class Program
{
// In the AOT you will find UserSessionService in Service Groups and AifUserSessionService under Services.
public static string sessionUrl = "/api/services/UserSessionService/AifUserSessionService/GetUserSessionInfo";
static void Main(string[] args)
{
string GetUserSessionOperationPath = string.Format("{0}{1}", ClientConfiguration.Default.UriString.TrimEnd('/'), sessionUrl);
var request = HttpWebRequest.Create(GetUserSessionOperationPath);
// If you call GetAuthenticationHeader with true you will the auth via AAD Web App, otherwise via Native AAD App
request.Headers[OAuthHelper.OAuthHeader] = OAuthHelper.GetAuthenticationHeader(true);
request.Method = "POST";
request.ContentLength = 0;
using (var response = (HttpWebResponse)request.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
using (StreamReader streamReader = new StreamReader(responseStream))
{
string responseString = streamReader.ReadToEnd();
Console.WriteLine(responseString);
}
}
}
Console.ReadLine();
}
}
but the OAuthHelper.GetAuthenticationHeader(true); give me Auth errors (Failed to authenticate with AAD by application with exception System.AggregateException)
I created a new WebApplication in Azure where my credentials are stored, and i write ActiveDirectoryClientAppId and ActiveDirectoryClientAppSecret on ClientConfiguration.
The user and password are from my org tenant (I login with these on my VM OneBox).
And this is my ClientConfiguration
public static ClientConfiguration OneBox = new ClientConfiguration()
{
UserName = "xxxxxx@xxxxxxx.xxx",
Password = "xxxxxxxxxxxxxxxx",
ActiveDirectoryTenant = "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
ActiveDirectoryClientAppId = "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
ActiveDirectoryClientAppSecret = "XKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
TLSVersion = "",
};
Maybe ActiveDirectoryTenant must be an URL instead of a GUID but I cannot find a proper documentation for these parameters.
Maybe i'm missing some steps.
Does someone facing the same issue or maybe can help?
Thanks.
Every discussion will be appreciated.