Hello,
does anyone know how can I make the API work with http authentication?
My server is configured with Shibboleth authentication and the user is successfully authentication via the Zabbix frontend.
However, the following code from the API that was working with internal authentication:
import simplejson as json
import urllib2
import sys
obj = {
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "xxxxx",
"password": "xxxxx"
},
"id": 1
}
url = 'http://xxxxxxxxx/zabbix/api_jsonrpc.php'
data = json.dumps(obj)
request = urllib2.Request(url, data, {'Content-Type': 'application/json'})
response = urllib2.urlopen(request)
res = json.load(response)
if 'error' in res:
# An error occurred; raise an exception
print 'An error occurred! %s' %res["error"]
sys.exit(-1)
hash_pass=res["result"]
print hash_pass
now gives me the following error because it does not manage to reach the zabbix API.
Traceback (most recent call last):
File "host_creation.py", line 20, in ?
res = json.load(response)
File "/usr/lib64/python2.4/site-packages/simplejson/__init__.py", line 267, in load
parse_constant=parse_constant, **kw)
File "/usr/lib64/python2.4/site-packages/simplejson/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.4/site-packages/simplejson/decoder.py", line 335, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.4/site-packages/simplejson/decoder.py", line 353, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
It gets blocked by the SSO authentication that comes before the Zabbix login.
Do you have any ideas?
Thanks.
Cheers,
Adriana
does anyone know how can I make the API work with http authentication?
My server is configured with Shibboleth authentication and the user is successfully authentication via the Zabbix frontend.
However, the following code from the API that was working with internal authentication:
import simplejson as json
import urllib2
import sys
obj = {
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "xxxxx",
"password": "xxxxx"
},
"id": 1
}
url = 'http://xxxxxxxxx/zabbix/api_jsonrpc.php'
data = json.dumps(obj)
request = urllib2.Request(url, data, {'Content-Type': 'application/json'})
response = urllib2.urlopen(request)
res = json.load(response)
if 'error' in res:
# An error occurred; raise an exception
print 'An error occurred! %s' %res["error"]
sys.exit(-1)
hash_pass=res["result"]
print hash_pass
now gives me the following error because it does not manage to reach the zabbix API.
Traceback (most recent call last):
File "host_creation.py", line 20, in ?
res = json.load(response)
File "/usr/lib64/python2.4/site-packages/simplejson/__init__.py", line 267, in load
parse_constant=parse_constant, **kw)
File "/usr/lib64/python2.4/site-packages/simplejson/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.4/site-packages/simplejson/decoder.py", line 335, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.4/site-packages/simplejson/decoder.py", line 353, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
It gets blocked by the SSO authentication that comes before the Zabbix login.
Do you have any ideas?
Thanks.
Cheers,
Adriana
Comment