Hello All,
I had a fully functional sync working with hybrid application on android and ios and cblite phonegap plugin. I use custom authentication for registering users with sync gateway .My app server returns me the cookie in setCookie header and then while performing replication i was manually setting the cookie header as follows :
var syncDefinitionPush = {
source: "budgetappdb",
headers: {
Cookie: "SyncGatewaySession=" + config.user.sessionId
},
target: {
url: REMOTE_SYNC_URL
},
continuous: true
};
var syncDefinitionPull = {
target: "budgetappdb",
headers: {
Cookie: "SyncGatewaySession=" + config.user.sessionId
},
source: {
url: REMOTE_SYNC_URL
},
continuous: true
};
While in normal scenarios when your sync gateway and your app server reside on the same domain then all the http requests should by default have a cookie header set once the app server has sent a setCookie header in response while performing custom authentication. But in case of cblite replication calls being made internally by cb lite to sync gateway, it didnt use the cookies and i was getting a 401 error while replicating on sync gateway. Hence i had to manually set the cookie header while starting the replication process.
All above was specifically needed on android. cblite on iOS automatically uses the cookie to all subsequent calls made to sync_gateway after authenticating with my app server.
The main issue is that this stuff used to work on android with cblite plugin version 1.0.3. But recently significant improvements were made in view indexing in android 1.0.4 and the build was given to us by one the team members. So we updated the plugin version to 1.0.4.Below is the thread where you can find the discussion and link to new plugin
The consequence was that now again cblite gets a 401 error on sync gateway while performing replication. Even though i have set custom cookie header while replicating still i guess somewhere in this new build the header is not being set and hence cookie is not being sent when cblite calls SG. Plus there is no way like in native API to setCookie so right now my sync does not work at all specially in android !
Any help how do i force cblite to use the SyncGatewaySession cookie when it makes http requests to SG for pull and push ?