node-neo4j
node-neo4j copied to clipboard
401 Unauthorized when supplying auth object in configuration.
Thanks for taking the time to take a look at this. I just updated and I'm getting a new error when I try to hit the database. In my package.json I have "neo4j": "^2.0.0-RC2".
I'm executing a MERGE and get the following error:
[Error][uncaughtException][neo4j.ClientError: 401 Unauthorized response for POST /db/data/transaction/commit: {
"errors": [
{
"code": "Neo.ClientError.Security.AuthorizationFailed",
"message": "No authorization header supplied."
}
]
}
Here is my configuration:
var db = new neo4j.GraphDatabase({
url: process.env.NEO4J_SERVER,
auth: {
username: process.env.NEO4J_USER,
password: process.env.NEO4J_PASS
},
headers: {},
proxy: null,
agent: null
});
And here is the query I'm using:
db.cypher({
queries: [{
query: "MERGE (k:thing { id: 0, name: 'Other' })"
}, {
query: "MERGE (k:thing { { id: 1, name: 'Another' })"
}]
}, function (err, nodes) {
if (err) {
throw (err);
}
});
Can you console.log your process.env.NEO4J_SERVER, NEO4J_USER, and NEO4J_PASS right before you pass them to the GraphDatabase constructor?
Obv. don't paste anything sensitive here =), but can you confirm that NEO4J_SERVER looks like 'http://something:7474', NEO4J_USER looks like 'neo4j', and NEO4J_PASS looks like 'password'?
Also, to see if it's a bug with passing a {username, password} object for auth, can you try passing the 'username:password' directly as a string instead?
This is a dev box, so nothing sensitive! Url is http://localhost:7474. I will update once I try the strings directly.
Changed to http://username:password@localhost:7474 and things are working!
Great, thanks! I'll look into what the bug is here and also add a test.