Command line template
curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: user_token [USER_TOKEN]" \
-H "App-Token: [APP_TOKEN]" \
'[GLPI_URI]/apirest.php/initSession'
Parameters to fill in
USER_TOKEN
: token generated in GLPI- My Settings (at the URI
[GLPI_URI]/front/preference.php
) - Tab “Main”
- Field “API token”
- My Settings (at the URI
APP_TOKEN
: token generated in GLPI (prerequisite : an API should have been configured before)- Setup>General>Api Clients (at the URI
[GLPI_URI]/front/preference.php
) - Select the API Client to use
- Tab “Api Client”
- Field “Application Token (app_token)”
- Setup>General>Api Clients (at the URI
GLPI_URI
: the location of GLPI
Commande line response
The response is a JSON :
Case 1 (the good one)
{"session_token":"[THE_SESSION_TOKEN_TO_USE]"}
Congratulation! The connection is succefuly initialized!
Memorize the token provided for the next calls.
Case 2
{"ERROR_WRONG_APP_TOKEN_PARAMETER","[ERROR_DESCRIPTION]"}
Verify the token entered for “App-Token
“.
In case of doubt, regenerate the token (check the box “Regenerate” and Save in GLPI) and use the new one.
Case 3
{"ERROR_GLPI_LOGIN_USER_TOKEN","[ERROR_DESCRIPTION]"}
Verify the token entered for “user_token
“.
In case of doubt, regenerate the token (check the box “Regenerate” and Save in GLPI) and use the new one.
Other Cases ?
Maybe a call from un unauthorized IP… So verify your Client API configuration on IPs section.
Maybe… sorry! I haven’t caused any other cases.