Search code examples
c#asp.nethttpmaximoibm-maximo-worker-insights

How to authenticate to Maximo 7.6 with .NET Core 3.1?


I'm not able to authenticate to get LtpaToken2 and JSESSIONID. Here is the code:

        string url = "http://maximo.local/maximo/"; //http://maximo.local/maximo/j_security_check?j_username=admin&j_password=admin

        string uri = "oslc/login";
        using (HttpClient client = new HttpClient())
        {

            client.BaseAddress = new Uri(url);
            string username = "admin";
            string password = "admin";

            client.DefaultRequestHeaders.Add($"Authorization", $"Basic {Base64Encode($"{username}:{password}")}");
            
            string paramentros = ""; 

            var response = client.PostAsync(uri, new StringContent(paramentros, Encoding.UTF8, "application/json")).Result;
            

            if (response.IsSuccessStatusCode)
            {
                var jsonString = await response.Content.ReadAsStringAsync();
            }

What could be wrong?


Solution

  • Does your Maximo store the username and password?

    Native Authentication in Maximo uses a header to log in through the rest api, but it's not as you have it.

    So you want to have the header maxauth and then the value is the base64 encoded userid:password.