jadell / neo4jphp

PHP wrapper of the Neo4j REST interface
Other
532 stars 137 forks source link

Getting "Invalid authorization token supplied" (Neo.ClientError.Security.AuthorizationFailed) error #165

Open AlexanderMatveev opened 9 years ago

AlexanderMatveev commented 9 years ago

I'm using Getting started code: https://github.com/jadell/neo4jphp/wiki/Getting-started Server has dbms.security.authorization_enabled=true, 7473 is http port.

I'm using neo4jphp:

use Everyman\Neo4j\Client, Everyman\Neo4j\Cypher\Query; $neo4j = new Everyman\Neo4j\Client('localhost', 7473); $neo4j->getTransport()->setAuth('...', '...'); This works fine.

But this line:

var_dump($neo4j->getServerInfo());

..returns error:

[message] => Invalid authorization token supplied. [code] => Neo.ClientError.Security.AuthorizationFailed

keelerm84 commented 9 years ago

I was just running into this. I was able to get it working by doing the following:

Change the password for the neo4j user by doing:

curl -H "Content-Type: application/json" -d '{"new_password":"whatever","password":"neo4j}' http://localhost:7474/user/neo4j/password

This will provide you with an authorization_token. If you then use that token as the password field in setAuth, you should be able to make successful requests.

AlexanderMatveev commented 9 years ago

@keelerm84 This means that we must change password every time?

keelerm84 commented 9 years ago

I don't think so. Once you have generated an authorization_token, that should persist until you specifically request that it generate a new one.