使用管理服务器凭据打开CouchDB会话 [英] open CouchDB session with admin server credential
问题描述
我已经创建了一个管理服务器。如果我尝试访问 http:// localhost:5984 / _utils / config.html
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响应,带有HTTP 401错误。消息是
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"
响应正常,内容消息告诉我我具有_admin的角色。
the response is ok and the content message tell me that I have the role of _admin.
为什么POST方法不起作用?
Why therefore the POST method not working?
推荐答案
您需要 POST
用户名和密码作为URL编码的 POST
正文或JSON对象:
You need to POST
the username and password as a URL encoded POST
body, or as a JSON object:
name=root&password=relax
或:
{
"name": "root",
"password": "relax"
}
您需要为其中一个设置正确的Content-Type标头。
And you need to set the correct Content-Type header for either.
查看官方文档 http://docs.couchdb.org/en/latest/api/server /authn.html 了解详情
这篇关于使用管理服务器凭据打开CouchDB会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!