Maximo Open Forum

 View Only

 REST Client Authentication

Jump to  Best Answer
  • Administration
Jason Johnson's profile image
Jason Johnson posted 09-11-2024 09:13

I'm trying to build a simple REST client and stumped on how to specify LDAP authentication. Anyone know how to do this? Here's my C# code:

using System.Net.Http.Headers;

string WhoAmI = "https://*.maximo.com/maximo/oslc/whoami";

using HttpClient client = new();
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

client.DefaultRequestHeaders.Add("maxauth", );  // need help here

await ProcessRepositoriesAsync(client);

static async Task ProcessRepositoriesAsync(HttpClient client)
{
    var json = await client.GetStringAsync(WhoAmI);
    Console.Write(json);
}

Dominic Russo's profile image
Dominic Russo  Best Answer

To use the API key, you'd first go into the Administration section of the Maximo-X work center (for Maximo 7.6.1.x) found at: [your Maximo URL here]/maximo-x/#/adminstrator/integration. There should be a tab for API keys where you can click the "Add API Key" button and then select a user and a token expiration length (-1 for permanent), then click Add. For any future requests then, all you need to do is include the API key as a URL parameter, which if I remember correctly is [your Maximo URL here]/[whatever your endpoint is]?apikey=[your API key goes here]

Keep in mind, with this approach, all activity from that application will now be under that specific user.

The other option would be to make a REST API request to the apikey endpoint first using the current user's supplied credentials. This will generate an API for that particular user and then just use that apikey for that user moving forward, but then you'd likely need to store that apikey locally which may or may not be secure depending on your application.

Hope that helps!

Rana Ahmed's profile image
Rana Ahmed

For LDAP, Maximo supports two kinds of authentication. BASIC and form based.

For FORM

POST /oslc/login

maxauth: <base64 encoded user:pass> <no body required>

For BASIC

POST /oslc/login
Authorization: BASIC <base64 encoded user:pass>
<no body required>

more info here
NextGen REST API (maximomize.com)

Jason Johnson's profile image
Jason Johnson

What about API key login? How would we do that?

Paul Adlington's profile image
Paul Adlington

Hi Jason,

When you have your api key you can add it to your client request headers like this

client.DefaultRequestHeaders.Add("apikey", apiKey);
Cheers
Paul