mcphargus / python-glpi

A python interface to the GLPI webservices plugin
GNU General Public License v2.0
15 stars 9 forks source link

Anonymous Calls working but not authenticated ones. #2

Open etechuganda opened 11 years ago

etechuganda commented 11 years ago

root@erp:~/python-glpi/pyglpi# python examples/list_computers.py examples/list_computers.py:25: RuntimeWarning: GLPI environment variables not locally set warnings.warn("GLPI environment variables not locally set", RuntimeWarning) Enter your GLPI hostname: localhost Enter your GLPI username: glpi Enter your password: True cnrdv6iq932r8gah49l0b9g037 <=== Session ID would seem to indicate the login has succeded? {u'faultCode': 13, u'faultString': u'Not authenticated'} {u'faultCode': 13, u'faultString': u'Not authenticated'} root@erp:~/python-glpi/pyglpi#

mcphargus commented 11 years ago

Not sure why this is happening. I'm getting the same results when trying to authenticate against localhost. I'm working on a fix, but for now, try using a fully qualified DNS name for your server's hostname.

EDIT: I can only confirm that this error occurs in the event of using localhost instead of: a fully qualified domain name with a working VirtualHost configuration in Apache.

etechuganda commented 11 years ago

Also seems to be happening when I use the hostname.

Enter your GLPI hostname: erp.xxxxxxxx.com Enter your GLPI username: glpi Enter your password: True b1tubhbing2vi7ofcr56pigvv1 {u'faultCode': 13, u'faultString': u'Not authenticated'} {u'faultCode': 13, u'faultString': u'Not authenticated'} root@erp:~/python-glpi/pyglpi#

The only difference is I am not using a virtualHost config instead I changed the BASEURL to '/glpi'

etechuganda commented 11 years ago

I copied some code from higher up in the GLPIClient.py which seems to work.

    request = urllib2.Request(self.url + urllib.urlencode(params))
    response = urllib2.urlopen(request).read()

    # response = urllib2.urlopen(self.__request__(params))

    return json.loads(response)
mcphargus commented 11 years ago

Strange. I'll do some more digging. I pulled the latest copy of this code onto a machine that didn't have it before and it worked for me freshouttathebox.

Like I said, I'll do more digging to see why this might not work on all installations, and I'll continue to assume you're working from the most recent commit to master.