python-glpi-api
python-glpi-api copied to clipboard
APPTOKEN is mandatory in python-glpi-api, while optional by GLPI
First of all, thank you for your work on this!
I noticed an aspect. apirest.php states (random internet accessible instance is for example at https://suporte.inss.gov.br/glpi/apirest.php/ ) this: "App-Token: authorization string provided by the GLPI API configuration. Optional." in the "Init Session" section.
Currently python-glpi-api requires apptoken:
- https://github.com/unistra/python-glpi-api/blob/47e35a1ae53d5fdb57ccd80bcdfe03adcf603404/glpi_api.py#L152
- https://github.com/unistra/python-glpi-api/blob/47e35a1ae53d5fdb57ccd80bcdfe03adcf603404/glpi_api.py#L176
Leaving aside documentation aspect, the following patches should fix these.
Currently from L148
# Set required headers.
headers = {
'Content-Type': 'application/json',
'Session-Token': session_token,
'App-Token': apptoken
}
To:
# Set required headers.
headers = {
'Content-Type': 'application/json',
'Session-Token': session_token,
}
if apptoken:
headers['App-Token'] = apptoken
Currently from L174
init_headers = {
'Content-Type': 'application/json',
'App-Token': apptoken
}
To:
init_headers = {
'Content-Type': 'application/json',
}
if apptoken:
init_headers['App-Token'] = apptoken