Announcement

Collapse

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

Collapse
X
  • 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" https://mycentreonserver.com/centreo...n=authenticate

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

    curl -H 'Content-Type: application/json' -H 'centreon-auth-token: "NWMyY2IwMGNkMTI2MDkuMTMzNjkwODk="' https://mycentreonserver.com/centreo...ts&action=list

    -====> "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:

    D="https://centreon.local/centreon/api/"
    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"
    else
    echo "ERROR - Could not get Auth Token"
    exit 2
    fi

    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


    NOTE1:
    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.


    cheers,
    Felipe Ferreira
    https://felipeferreira.net

    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
    www.felipeferreira.net

    Comment

    Working...
    X