open CouchDB session with admin server credential

馋奶兔 提交于 2019-12-11 19:49:18

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/19832324/open-couchdb-session-with-admin-server-credential

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!