Anyway to authorize a Sync Gateway replication request?


Is there a way to authorize a replication request?
I was thinking of using the Public API instead of the Admin API. However, I am not sure if username and password can be passed using the replication config.


you can pass SyncGatewaySession instead of username/password in replication config. for example

curl --request POST \
  --url \
  --header 'content-type: application/json' \
  --data '{\n    "source": {\n          "headers": {\n              "Cookie":"SyncGatewaySession=9d0d312a32e858dfe26f620c8d5f9c0000000000"\n          },\n          "url":""\n    },\n    "target" : "cblitedb"\n}'

Thanks for the reply. BTW, where can I find this in the document?



source (string, optional): Identifies the database to copy revisions from. Can be a string containing a local database name or a remote database URL, or an object whose url property contains the database name or URL. Also an object can contain headers property that contains custom header values such as a cookie. ,
target (string, optional): Identifies the database to copy revisions to. Same format and interpretation as source. ,

Thank you so much for the link.

I keep getting:

{“error”:“Bad Request”,“reason”:“Invalid JSON: “json: cannot unmarshal object into Go value of type string””}

with the following:

curl -i --request POST
–header ‘content-type: application/json’
–data ‘{“source”:{“headers”:{“Cookie”:“SyncGatewaySession=5309f18205fcbf3d691e6ddcc49c620550fc811e”},“url”:“"},“target”:"”}’

4985 is admin port for default.
you should send to public port 4984 for default.

what do you mean
source →
target →

it is the same bucket with admin port and public port.


As of version 1.4, /_replicate is no longer available with the public API.

I am trying to authenticate my slave with the master. Source == master. Target is “self” admin API where I want to copy the content.


My replication is running fine using admin API (for source and target) with SSL through a load balancer. My goal is to authenticate the replication request from the slave to the master possibility using the public API port as the “Source”.

Anyway, thanks for the help.

Hey Felixfong, we are also interested in running replication using the public API from the SG config. Were you able to successfully set that up?

​Sorry, we have since moved away from this idea.