truly-systems / glpi-sdk-python

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

Error: "user_token "+self.token_auth TypeError: can only concatenate str (not "tuple") to str #32

Open wtccosta opened 5 years ago

wtccosta commented 5 years ago

When I try to run the installation guide examples, such as listing tickets, this error appears: "user_token "+self.token_auth Traceback (most recent call last): File "C:/Users/warde/PycharmProjects/pyGLPI/connection.py", line 13, in glpi.get_all('ticket') File "c:\users\warde\pycharmprojects\pyglpi\venv\src\glpi\glpi\glpi.py", line 589, in get_all self.init_api() File "c:\users\warde\pycharmprojects\pyglpi\venv\src\glpi\glpi\glpi.py", line 544, in init_api self.api_session = self.api_rest.get_session_token() File "c:\users\warde\pycharmprojects\pyglpi\venv\src\glpi\glpi\glpi.py", line 271, in get_session_token self.set_session_token() File "c:\users\warde\pycharmprojects\pyglpi\venv\src\glpi\glpi\glpi.py", line 211, in set_session_token headers["Authorization"] = "user_token "+self.token_auth TypeError: can only concatenate str (not "tuple") to str

I use python version 3.7

Eleazarus commented 5 years ago

Hello,

Same error on Python 2.7.5, with the last version 0.4.0 (GLPI 9.4.3). Is this still maintained?

jsalatiel commented 4 years ago

Same problem here with python 2.7.15 with the last version 0.4.0 .

KongNan commented 4 years ago

3.7, same error.

polkaa commented 4 years ago

Mistake is in the utiliszation of GLPI constructor :

glpi = GLPI(url, token, (user, password))

(README) while the constructor has the following signature :

def __init__(self, url, app_token, auth_token,
                 item_map=None):

(glpi/glpi.py)

GLPI constructor does not take a tuple of user and password as argument but an authentification token.

manubuhay commented 1 year ago

Mistake is in the utiliszation of GLPI constructor :

glpi = GLPI(url, token, (user, password))

(README) while the constructor has the following signature :

def __init__(self, url, app_token, auth_token,
                 item_map=None):

(glpi/glpi.py)

GLPI constructor does not take a tuple of user and password as argument but an authentification token.

Thank you, all the while I thought my code was the issue.