我正在使用 cookie Auth 实现自定义身份验证。所以,我在玩同步网关 REST API 来创建用户和会话。我可以成功创建用户,但无法通过 /_session API 创建会话。以下是我遵循的步骤。
1.创建用户
POST /cookbook/_user/ HTTP/1.1
Host: localhost:4985
Content-Type: application/json
{
"name": "chef123",
"password": "1234"
}
2.获取用户
GET /cookbook/_user/ HTTP/1.1
Host: localhost:4985
Content-Type: application/json
Respone :["chef123"]
3.创建会话
POST /cookbook/_session HTTP/1.1
Host: localhost:59840
Content-Type: application/json
{
"name": "chef123",
"ttl": 1800
}
Expected:
{
"cookie_name": "SyncGatewaySession",
"expires": "2014-11-07T16:42:11.675519255-08:00",
"session_id": "c2425fa7d734bc8c3f6c507854166bef56a5fbc6"
}
Instead received:
{"authentication_handlers":["default","cookie"],"ok":true,"userCtx":{"channels":{},"name":null}}
任何人都可以解释为什么 API 会给出以下响应。
{"authentication_handlers":["default","cookie"],"ok":true,"userCtx":{"channels":{},"name":null}}