open CouchDB session with admin server credential

2019-09-05 22:20发布

I have create an admin server. If I try to access to http://localhost:5984/_utils/config.html

futon ask me the credential for administrator, and if I digit username e password all work perfectly. But if I try to run the command:

curl -X POST http://username:password@localhost:5984/_session

couchdb response with a HTTP 401 error. The message is

{error":"unauthorized","reason":"Name or password is incorrect."}

but I'm sure that the username and the password are correct. In effect if I try to run the command:

curl -X GET "http://username:password@localhost:5984/_session"

the response is ok and the content message tell me that I have the role of _admin.

Why therefore the POST method not working?

标签: couchdb
1条回答
混吃等死
2楼-- · 2019-09-05 22:55

You need to POST the username and password as a URL encoded POST body, or as a JSON object:

name=root&password=relax

or:

{
    "name": "root",
    "password": "relax"
}

And you need to set the correct Content-Type header for either.

See the official docs http://docs.couchdb.org/en/latest/api/server/authn.html for details

查看更多
登录 后发表回答