我应该如何将凭据传递给SparqlRemoteEndpoint类对象?

时间:2018-12-10 07:16:54

标签: sparql graphdb dotnetrdf

我正在使用GraphDB数据库。我希望SparqlRemoteEndpoint类对象(link)与我的数据库连接。 但是,当我使用setCredentials(username, password)放置凭据时,会说401 unauthorized,因为它使用摘要身份验证,而GraphDB使用基本身份验证:

代码是:

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);

我应该如何解决此身份验证类型问题?

2 个答案:

答案 0 :(得分:2)

感谢您的评论。通过将ForceHttpBasicAuth设置为true(默认为False)来工作

声明是:

VDS.RDF.Options.ForceHttpBasicAuth = true;

答案 1 :(得分:1)

根据版本,您可以使用带有有效base-64编码的用户名/密码组合的基本身份验证作为标头,也可以使用JWT令牌。可以在http://graphdb.ontotext.com/documentation/free/authentication.html

找到一些指导

我希望这会有所帮助。