Search code examples
neo4jneo4jclient

How to include network credentials in Neo4JClient?


So tipically if you install Neo4j in your development environment, you will have a local hosted version of the Neo4Jserver, which usually you can browse with: localhost:7474/db/data.

Your code is like this:

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

However, one day you will want to connect to your Cloud-based Neo4J Server (Heroku, Azure, etc.) Of course, that means you will have to provide Network credentials. If you only use your bare hands, it could be like this:

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

But how can I include network credentials to connect with Neo4JClient? or is there another option that I don't know?


Solution

  • We support the standard URI syntax for basic authentication credentials:

    var client = new GraphClient(new Uri("http://user:pass@localhost:7474/db/data"));