Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 Unauthorized when supplying auth object in configuration. #171

Open
JosephScript opened this issue Sep 24, 2015 · 5 comments
Open

401 Unauthorized when supplying auth object in configuration. #171

JosephScript opened this issue Sep 24, 2015 · 5 comments

Comments

@JosephScript
Copy link

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);
            } 
        });
@aseemk
Copy link
Member

aseemk commented Sep 24, 2015

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'?

@aseemk
Copy link
Member

aseemk commented Sep 24, 2015

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?

@aseemk aseemk added this to the v2 redesign milestone Sep 24, 2015
@JosephScript
Copy link
Author

This is a dev box, so nothing sensitive! Url is http://localhost:7474. I will update once I try the strings directly.

@JosephScript
Copy link
Author

Changed to http://username:password@localhost:7474 and things are working!

@aseemk
Copy link
Member

aseemk commented Sep 24, 2015

Great, thanks! I'll look into what the bug is here and also add a test.

@aseemk aseemk added bug and removed question labels Sep 24, 2015
@aseemk aseemk self-assigned this Sep 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants