1

因此,如果您在开发环境中安装 Neo4j,您将拥有 Neo4Jserver 的本地托管版本,通常您可以通过以下方式浏览:localhost:7474/db/data。

你的代码是这样的:

var client = new GraphClient(new Uri("http://localhost:7474/db/data"));
client.Connect();

但是,有一天您会想要连接到基于云的 Neo4J 服务器(Heroku、Azure 等)。当然,这意味着您必须提供网络凭据。如果你只用你的双手,它可能是这样的:

var http = (HttpWebRequest)WebRequest.Create(new Uri("http://<<your_REST_query"));
var cred = new NetworkCredential("yourusername", "yourpassword");

http.Credentials = cred;

var response = http.GetResponse();
var stream = response.GetResponseStream();

但是如何包含网络凭据以连接 Neo4JClient?还是有其他我不知道的选择?

4

2 回答 2

1

我们支持基本身份验证凭据的标准 URI 语法:

var client = new GraphClient(new Uri("http://user:pass@localhost:7474/db/data"));
于 2012-11-08T11:36:27.380 回答
0

版本 1.1.0.0

var username = "app_username"
var password = "1@mGr@phG0d"    
var client = new GraphClient(new Uri("http://localhost:7474/db/data"), username, password);
于 2016-03-14T03:39:46.027 回答