Closed blippercop closed 7 months ago
Hi, sorry for the late answer.
It should already be possible without modifying the library. By default, requests
removes headers that have None as value (pinpointed to https://github.com/psf/requests/blob/main/src/requests/sessions.py#L82). So, you just need to set the APP_TOKEN to None and the header will not be included.
The following code works for me:
import glpi_api
URL = 'http://127.0.0.1:8080/apirest.php'
APPTOKEN = None
USERTOKEN = 'FIXME'
with glpi_api.connect(URL, APPTOKEN, USERTOKEN) as glpi:
print(glpi.search('Ticket'))
Aha! Setting it to None. I tried omitting it which did not work as it was required. So I assumed it is not possible. Thanks, that helped! It works now! :)Am 26.10.2023 um 14:09 schrieb François Ménabé @.***>: Hi, sorry for the late answer. It should already be possible without modifying the library. By default, requests removes headers that have None as value (pinpointed to https://github.com/psf/requests/blob/main/src/requests/sessions.py#L82). So, you just need to set the APP_TOKEN to None and the header will not be included. The following code works for me: import glpi_api
URL = 'http://127.0.0.1:8080/apirest.php' APPTOKEN = None USERTOKEN = 'FIXME'
with glpi_api.connect(URL, APPTOKEN, USERTOKEN) as glpi: print(glpi.search('Ticket'))
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
Having this code:
I am able to get the tickets by the API. Is it possible to add the user_token method to the authentication methods? Thanks