Skip to main content
Solved

Can't get authentication token since upgrade to 22.04

  • February 16, 2023
  • 5 replies
  • 337 views

Forum|alt.badge.img+7

Hello,
since we last upgrade from 20.10 to 22.04 we have a couple of perl script that fail. It seems as if the URL for the API changed and the authentication token could no be retreive.

This is the request in the script, which worked before the upgrade:


my $resauth = $ua->request(POST "https://${hostname}/centreon/api/index.php?action=authenticate", [username => "$username", password => "$password"]);

 

And the error is:


malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "<!DOCTYPE HTML PUBLI...") at /opt/clapi/ExportCentreonServices.pl line 75.
 

What can be wrong?

Regards,

Enrique

Best answer by ponchoh

👋

curl

curl "https://x.x.x.x/centreon/api/index.php?action=authenticate" -F "username=\"aaaaa\"" -F "password=\"xxxx\""

or

 

5 replies

Forum|alt.badge.img+7
  • Author
  • Steward ***
  • February 16, 2023

Also, using curl for that URL gives 404 Not Found error.


ponchoh
Centreonian
Forum|alt.badge.img+14
  • Centreonian
  • Answer
  • February 16, 2023

👋

curl

curl "https://x.x.x.x/centreon/api/index.php?action=authenticate" -F "username=\"aaaaa\"" -F "password=\"xxxx\""

or

 


Forum|alt.badge.img+7
  • Author
  • Steward ***
  • February 17, 2023

Hello ponchoh

 

using curl with the username and password options as you pointed again gives 404 Not Found error.

 

Using the second method on Firefox gives "Unauthorized"


ponchoh
Centreonian
Forum|alt.badge.img+14
  • Centreonian
  • February 17, 2023

I did run it in 22.04 anything in the logs?


Forum|alt.badge.img+7
  • Author
  • Steward ***
  • March 30, 2023

Hello,

sorry for the late reply.

The script is working again but using http:// instead of https:// to authenticate. Since the script runs in the locally in the central server it is ok for us now.

 

We still don’t know what was broken during the upgrade.

 

Regards,

Enrique