Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-10-2021 10:31 AM
Hello,
i'm trying to use this API to reset password of a user on Neo4j 4.1.1 but i receive 404:
curl -v -H "Content-Type: application/json" -X POST -d '{"password":"Accenture.1"}' -u neo4j:neo4j http://localhost:7474/user/neo4j/password
POST /user/neo4j HTTP/1.1
Authorization: Basic bmVvNGo6bmVvNGo=
User-Agent: curl/7.29.0
Host: localhost:7474
Accept: /
Content-Type: application/json
Content-Length: 26
Can anyone help me?
Thanks,
Alessio
Solved! Go to Solution.
02-11-2021 05:30 AM
????
So this is simply to reset the default password for the neo4j user and before startup? is that correct?
if so we would recommend bin/neo4j-admin set-initial-password
02-10-2021 11:25 AM
that is the expected behavior as /user/neo4j/password is to address 'native' users which were recorded in data/dbms/auth whereas for 4.0.x forward usernames/passwords are now recorded in the system
database. Please use built-in stored procedure dbms.security.changePassword()
and as descrbed at Procedures - Operations Manual
You could still utilize REST to call this, i.e. have REST call a Cypher statement
02-10-2021 11:48 AM
Thanks Dana,
Can you give me an example of Rest call a cypher statement?
I need to change the intial neo4j password using a rest client.
Thanks a lot!
Alessio
02-10-2021 12:31 PM
this is described in the documentation at Cypher transaction API - HTTP API
and Run queries inside a transaction - HTTP API which states sending a body similar to
{
"statements" : [ {
"statement" : "CREATE (n) RETURN n"
} ]
}
to which you would replace CREATE (n) RETURN N;
with call dbms.security.changePassword('football');
for example which would set the password to football
02-11-2021 12:47 AM
Thanks Dana!
I have tried with this curl:
curl -v -H "Content-Type: application/json" -X POST -d '{ "statements" : [ { "statement" : "call dbms.security.changePassword('test.1'); " } ]}' -u neo4j:neo4j http://localhost:7474/db/neo4j/tx
and i recieved this response:
{"results":,"errors":[{"code":"Neo.ClientError.Security.CredentialsExpired","message":"Permission denied.\n\nThe credentials you provided were valid, but must be changed before you can use this instance. If this is the first time you are using Neo4j, this is to ensure you are not using the default credentials in production. If you are not using default credentials, you are getting this message because an administrator requires a password change.\nChanging your password is easy to do via the Neo4j Browser.\nIf you are connecting via a shell or programmatically via a driver, just issue a ALTER CURRENT USER SET PASSWORD FROM 'current password' TO 'new password'
statement against the system database in the current session, and then restart your driver with the new password configured."}],"commit":"http://localhost:7474/db/neo4j/tx/1/commit"}
So i try to launch this one:
curl -v -H "Content-Type: application/json" -X POST -d '{ "statements" : [ { "statement" : "ALTER CURRENT USER SET PASSWORD FROM 'neo4j' TO 'test.1'" } ]}' -u neo4j:neo4j http://localhost:7474/db/neo4j/tx
But i have recieved the same response.
Is there any curl to do the initial reset of default neo4j password?
Thanks a lot!
Alessio
02-11-2021 05:30 AM
????
So this is simply to reset the default password for the neo4j user and before startup? is that correct?
if so we would recommend bin/neo4j-admin set-initial-password
02-11-2021 08:23 AM
Thanks a lot!!
This solution is ok for me
09-15-2022 08:23 PM
This may be a bit late, but though to post a solution that worked for me. The change password statement needs to be run against the system db. So the url in curl would be http://localhost:7474/db/system/tx instead of http://localhost:7474/db/neo4j/tx
curl -v -H "Content-Type: application/json" -X POST -d '{ "statements" : [ { "statement" : "ALTER CURRENT USER SET PASSWORD FROM 'neo4j' TO 'test.1'" } ]}' -u neo4j:neo4j http://localhost:7474/db/system/tx
This worked perfectly for me
All the sessions of the conference are now available online