Reputation: 197
Python's SPARQLWrapper has setCredentials to specify credentials for SPARQL query, but it is meant for the current SPARQL endpoint. So, I wonder how to specify credentials for 2nd endpoint in the context of federated query, using SERVICE. I tried with simple syntax in SPARQL: http://user2:password2@example2.com/sparql but it does not seem to work. As for the code, I have something like this in Python:
sparql = SPARQLWrapper('https://example1.com/sparql')
sparql.setCredentials("user1", "password1")
query_content = """
SELECT *
WHERE {
?s owl:sameAs ?o .
SERVICE <https://user2:password2@example2.com/sparql>
{
?a owl:sameAs ?s .
}
}
"""
query = query_content
sparql.setQuery(query)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
print(results)
Many thanks!
Upvotes: 0
Views: 354