Authenticate API error while deploying host template

Hello,

I’m pretty new to linux and icinga, but with the guides and the communicty help I already managed to setup icinga2, icingaweb2 and since yesterday also the director.

Now I want to create a host template in the director, but when I press “deploy” I get the following error message:
Unable to authenticate, please check your API credentials (RestApiClient.php:149)
Despite my searches on the web I didn’t find a solution yet. I thank you guys to guide me in the debugging of this little problem.

Hi @Jelle,

Welcome to the Icinga community, Be sure to earn some awesome badges like the one for reading the guidelines found here:

https://community.icinga.com/guidelines

It is good to see you managed to install a lot already on your own!

The error message you have is luckily quite clear!

You probably missed this in all your enthusiasm (setting up the api):

You can combine it with this piece of documentation:

If you did all this be sure you did enable the API and restarted icinga after you did so :slight_smile:

If you need anything happy to help!

Hi & welcome,

to be sure, did you configured an API user like mentioned in the docs? https://icinga.com/docs/director/latest/doc/04-Getting-started/

And did you add this user here?

Hello,

Thank you for the quick reply both of you!
@belastingvormulier
image
How can I check the API is enabled?
Icinga is restarted without problems .
@stevie-sy
I did configure the API user like mentioned, well I at least tried.
But I didn’t add the user in the Director.
I added him now, but the error still occurs:
image

image

I more information is need, just let me know and I’ll provide the necessary!

can you please write the ouptut from
icinga2 feature list

the ouptut should look like this


Theat menas the feature ‘api’ should bie in the list "enabled features’ :wink:

for enabling a feature the command is
icinga2 feature enable [feature name]

I just checked it, the API is enabled:

HI @Jelle,

Can you check the “preview” option in the user configuration in the director?
It should look something like this:

Screenshot 2020-11-27 at 14.34.34

If so, perhaps the problem lies somewhere else :slight_smile:

Can you do a manual API request on the command line ?

curl -k -s -u username:password 'https://localhost:5665/v1'

More examples here:

Hello @belastingvormulier,

Preview:
image
Looks exactly the same (except for the name but I don’t think the user should be mandatory “root”)

manual API request:


To me it looks like I did something wrong in the director setup ? But I cannot find where :confused:

Hi @Jelle,

So far so good :smiley:

  • api enabled
  • username and password correct
  • api user in the director
  • localhost accepts the request

I believe that it then must be a configuration error indeed.

What did you specify as endpoint ?
(note this is in a vagrant box that i run locally)

Hero!
That was the solution, I added the wrong user there (in my first setup attempt I used root as api user, but was a bit confusing so I changed it to icingadirector).
Changing my user there to the correct one and now I can deploy my template.
Now I can continue with the setup.

1 Like