samir jamadar
samir jamadar

Reputation: 141

How should I pass the credentials to SparqlRemoteEndpoint class object?

I am using GraphDB database. I want SparqlRemoteEndpoint class object (link) to connect with my database. But, while I am putting my credentials using setCredentials(username, password) it says 401 unauthorized as it uses digest authentication and GraphDB uses basic authentication:

The code is :

string query = "SELECT * WHERE {?s ?p ?o} LIMIT 50";
var endpoint = new VDS.RDF.Query.SparqlRemoteEndpoint(new Uri("http://localhost:7200/repositories/786"));
endpoint.SetCredentials("admin","admin");
SparqlResultSet results = endpoint.QueryWithResultSet(query);

How should I resolve this authentication type issue?

Upvotes: 0

Views: 442

Answers (2)

samir jamadar
samir jamadar

Reputation: 141

Thanks for your comment. It works by setting the ForceHttpBasicAuth to true (It is False by default)

The statement is :

VDS.RDF.Options.ForceHttpBasicAuth = true;

Upvotes: 2

Konstantin Petrov
Konstantin Petrov

Reputation: 1142

Depending on the version you can use either Basic Authentication with a valid base-64 encoded username/password combinations as a header or use JWT token. Some guidance can be found at http://graphdb.ontotext.com/documentation/free/authentication.html

I hope this will help.

Upvotes: 1

Related Questions