New forum rules

The forum get new posts rules.

A new user will be moderate for new post. After five valid posts, the user will be to have right to post without moderation.

If you have some issue to post or to connect, contact us.
See more
See less

API Always returning Unauthorized

  • Filter
  • Time
  • Show
Clear All
new posts

  • API Always returning Unauthorized

    My , dozens times tried, requests :

    - Request *AUTH* :

    curl -s -k -X POST -d "username=myuser&password=mypassword"

    -====> Authenticated returned token: "NWMyY2IwMGNkMTI2MDkuMTMzNjkwODk="
    - Peticion *LIST* :

    curl -H 'Content-Type: application/json' -H 'centreon-auth-token: "NWMyY2IwMGNkMTI2MDkuMTMzNjkwODk="'

    -====> "Unauthorized"

    I've checked both checkboxes "Reach API Configuration" and "Reach API realtime" at my Centreon >> Configurations >> Contacts Users <myuser> >> Centreon Authentication

    Authentication source is LDAP.

    Any idea please ? I've tested this many times, googled a lot and all I found is an old "change centreon_auth_token by centreon-auth-token" ...nothing else

  • #2
    Hey.. I had some problem! Lost like an hour to get it working.. Documentation is very poor of EXAMPLES. Please update documentation with real example using curl.

    alvaro try:

    TOKEN=$(curl -s -X POST -F 'username=admin' -F 'password=sQ123CgUy39rj' "${D}index.php?action=authenticate" | jq '.authToken' |sed 's/"//g')
    if [ $? -eq 0 ]; then
    echo "OK - Got Auth Token $TOKEN"
    echo "ERROR - Could not get Auth Token"
    exit 2

    URL="${D}index.php?action=list&object=centreon_rea ltime_services&limit=60&viewType=problems&sortType =name&order=desc&fields=id,description,host_id,hos t_name,state,output"
    curl -vv -H "Content-Type: application/json" -H "centreon-auth-token: $TOKEN" $URL

    I am still not able to list service by getting only CRITICAL status...

    URL="${D}index.php?action=list&object=centreon_rea ltime_services&viewType=problems&status=critical&f ields=host_name,state,output"

    Lost another hour and no success... documentation is wrong or api broken? I tried also state=2 or status=2 nothing worked I am running
    Centreon 2.8.24

    let me know if it works for you...

    I find this API is hard to work with

    NOTE2: If it dosent work try using LOCAL account just for that case.

    Felipe Ferreira

    Last edited by xoroz; 2 weeks ago.
    CentOS 5.5 x64 / Nagios 3.2.2 / Centreon 2.1.10
    Monitoring: 467 Hosts / 2109Services 16th Server
    NdoUtils 1.49,NagiosPlugins 1.4.14, NagVis 1.5.1, Distributed Architeture(howto)

    Nagios/Centreon Custom Scripts / Troubleshooting