Sync-gateway returns this error 401 Login required, I don't understand why. Because I put in the header the basic auth with username and password, our root user to access to Couchbase.
I did a get on Sync-Gateway and it returns an error: 401 Login required.
2019-09-16T07:53:07.554Z HTTP: #9650: GET /bucket_01/_changes?style=all_docs&active_only=true&include_docs=true&feed=longpoll&since=603276
2019-09-16T07:53:07.554Z HTTP: #9650: --> 401 Login required (0.5 ms)
My Sync-Gateway configuration:
[...]
"bucket_01" : {
"server": "http://127.0.0.1:8091",
"bucket":"bucket_01",
"revs_limit": 20,
"username": "admin",
"password": "pwd",
"users": { "GUEST": { "disabled": true } },
"sync": [...],
}
[...]
UPDATE 18.09.2019
[...]
"bucket_01": {
"server": "http://127.0.0.1:8091",
"bucket":"bucket_01",
"revs_limit": 20,
"username": "admin",
"password": "pwdAccess",
"users": { "GUEST": { "disabled": true }, "admin": {"password": "pwd"} },
"sync": `function(doc, oldDoc) { [...] }`
[...]
The call:
[...]
var sync_gateway_url = 'http://our_server/db/bucket_01/'
var querystring = 'style=all_docs&active_only=true&include_docs=true&feed=longpoll&since=0';
var options = {
url: sync_gateway_url + '_changes?' + querystring,
auth: {
user: 'admin',
pass: 'pwd',
sendImmediately: false
},
timeout: 10000,
};
[...]
2019-09-18T16:07:39.526+02:00 [INF] HTTP: #4205: GET /bucket_01/_changes?style=all_docs&active_only=true&include_docs=true&feed=longpoll&since=603372 (as GUEST)
2019-09-18T16:07:39.526+02:00 [INF] HTTP: #4205: --> 401 Login required (0.3 ms)
2019-09-18T16:07:39.532+02:00 [INF] HTTP: #4206: GET /bucket_01/_changes?style=all_docs&active_only=true&include_docs=true&feed=longpoll&since=603372 (as admin)
Where / how have you configured the sync gateway user ? Make sure that the user is configured via sync gateway config or via REST API. Confirm the list of users by doing a GET.