Cordova/Phonegap authentication


#1

Hello,

I’m developing cordova app with couchbase lite plugin and I would like to sync data to server. But I don’t want to use facebook authorization because that doesn’t go with the applications ideology. I would like to use basic authorization for now but it doesn’t work. Now I’ve taken example of todo lite application and some other topics which suggest that basic auth should work just by adding username and password to server url. The response I get is {“session_id”:“repl001”}. Could aynone suggest or explain to me what is wrong or what have I understood wrong? Down below are the lines of code which are executed to start the replication process.

var push = {
    source : "todo",
    target : "http://testuser:testpass@myprivatepad.fr:4984/gadgetbook/",
    continuous : true
};
coax.post([databaseUrl, "_replicate"], push, function(err, ok) {
    alert("Response -> " + JSON.stringify(ok));
});

#2

Hi @Braivo,

Does the user with name testuser and password testpass exist on Sync Gateway?
Users must be created through the Admin REST API on the user endpoint.
This tutorial explains how to set up a NodeJS app server to have signup in an Android app (i.e. exposing the user endpoint above publicly to client apps). The same concept applies with the Cordova plugin.

James


#3

No, it doesn’t. Somehow it slipped through my eyes.
Thank you very much. This helped a lot!