简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM