Anyway to authorize a Sync Gateway replication request?

Hi,

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.

Thanks,
-Felix.

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

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

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

Regards,
-Felix.

yes,FYI

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
–url https://pe-psg001.example.com:4985/_replicate
–header ‘content-type: application/json’
–data ‘{“source”:{“headers”:{“Cookie”:“SyncGatewaySession=5309f18205fcbf3d691e6ddcc49c620550fc811e”},“url”:“https://un-sg001.example.com:4984/ped"},“target”:"https://un-psg001.example.com:4985/ped”}’

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

what do you mean
source → https://un-sg001.example.com:4984/ped
and
target → https://un-psg001.example.com:4985/ped

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

Hi,

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.

fyi
https://developer.couchbase.com/documentation/mobile/1.4/guides/sync-gateway/running-replications/index.html

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.