Skip to content

Using Auth credentials with SPARQLStore VS SPARQLUpdateStore #755

@lambdamusic

Description

@lambdamusic

Hi, just a comment about something I discovered but can't quite explain.

I am trying to access a SPARQL endpoint which requires authentication, but for some reason the code below fails unless I substitute SPARQLStore with SPARQLUpdateStore.

Is that the expected behaviour?

In [1]: import rdflib
INFO:rdflib:RDFLib Version: 4.2.1

In [2]: g = rdflib.ConjunctiveGraph('SPARQLStore')

In [3]: g.store.setCredentials('my','password')

In [4]: sparql='http://graphdb/repositories/articles'

In [5]: g.open(sparql)

In [6]: g.query("select * where {?x a ?b} limit 10")
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-12-5840b5e5b34f> in <module>()
----> 1 g1.query("select * where {?x a ?b} limit 10")

/usr/local/lib/python2.7/site-packages/rdflib/graph.pyc in query(self, query_object, processor, result, initNs, initBindings, use_store_provided, **kwargs)
   1068                     and '__UNION__'
   1069                     or self.identifier,
-> 1070                     **kwargs)
   1071             except NotImplementedError:
   1072                 pass  # store has no own implementation

/usr/local/lib/python2.7/site-packages/rdflib/plugins/stores/sparqlstore.pyc in query(self, query, initNs, initBindings, queryGraph, DEBUG)
    256         self.setQuery(query)
    257
--> 258         return Result.parse(SPARQLWrapper.query(self).response)
    259
    260     def triples(self, (s, p, o), context=None):

/usr/local/lib/python2.7/site-packages/SPARQLWrapper/Wrapper.pyc in query(self)
    599             @rtype: L{QueryResult} instance
    600         """
--> 601         return QueryResult(self._query())
    602
    603     def queryAndConvert(self):

/usr/local/lib/python2.7/site-packages/SPARQLWrapper/Wrapper.pyc in _query(self)
    579                 raise EndPointInternalError(e.read())
    580             else:
--> 581                 raise e
    582
    583     def query(self):

HTTPError: HTTP Error 403: Forbidden

thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions