truly-systems / glpi-sdk-python

GLPI SDK writen in Python.
Apache License 2.0
22 stars 21 forks source link

User token auth is broken #17

Closed poikilotherm closed 5 years ago

poikilotherm commented 6 years ago

Hi @mtulio,

I just tried to use your module with a User Token (generate in profile) and noticed that this is not supported.

Seems to be related to https://github.com/truly-systems/glpi-sdk-python/blob/e0bb986bb58dfffd2c83c25e882931f919a274f6/glpi/glpi.py#L213 using the static auth parameter.

As far as I understand the REST API docs, one needs to send an Authorization: user_token xxx header. The auth param of request() seems to default to basic auth.

Could you have a look at this?

Thanks! Poikilotherm

gBuff commented 6 years ago

Hello,

I've been facing the same problem.

To fix this (temporarily), I've change line 209 in glpi.py :

if self.token_auth is not None: 
    auth = self.token_auth

by

if self.token_auth is not None: 
    headers["Authorization"] = "user_token "+self.token_auth