I secured my SPARQL endpoint via SQL Accounts according to VirtSPARQLProtectSQLDigestAuthentication.
Before this operation, I can get the data through the code:
from SPARQLWrapper import SPARQLWrapper, JSON, DIGEST
sparql = SPARQLWrapper("http://example.org/sparql")
sparql.setQuery("...")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
And after that, I use the DIGEST way to get the data,
from SPARQLWrapper import SPARQLWrapper, JSON, DIGEST
sparql = SPARQLWrapper("http://example.org/sparql")
sparql.setHTTPAuth(DIGEST)
sparql.setCredentials('login', 'password')
sparql.setQuery("...")
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
, Error 401 occured:
Traceback (most recent call last): File "1.py", line 21, in results = sparql.query().convert() File "/usr/local/lib/python2.7/site-packages/SPARQLWrapper/Wrapper.py", line 601, in query return QueryResult(self._query()) File "/usr/local/lib/python2.7/site-packages/SPARQLWrapper/Wrapper.py", line 581, in _query raise e urllib2.HTTPError: HTTP Error 401: Unauthorized
Anything wrong with my operations? The username and password are both correct.
Appreciate that if anyone can help.