Phonegap Plugin examples with basic auth


Integrating the Android Couchbase Mobile sdk is pretty easy. You can find great example (ToDo Lite) and test different authentication (facebook, basic and so on), replication, etc…

With phonegap seems more complicated. There is not enough documentation (or I could not find it) and understand the example becomes a complex task. I want to develop a phonegap app (ios and android support) with basic authentication. Is there any example using basic authentication (user/pass)? Any tutorial to start learning the phonegap plugin? ToDo Lite just has facebook auth.



Hey @javilin,

The following isn’t PhoneGap, but it still operates on Apache Cordova:

More importantly, you’ll want to take a look at how it uses the Couchbase Lite RESTful APIs found here:

Definitely start there and reach out if you have particular questions. That repository is a work in progress, but it will soon have authentication and replication included.



Sorry about the lack of PhoneGap docs! We’re aware of it and hope to improve them.

With PhoneGap you use the REST API (which is 98% the same as the CouchDB REST API). To replicate you POST to /_replicate. To specify Basic auth you add the username and password to the server URL, like


Thanks @jens

Should I include any other header parameter (cookie, session id, etc) into the request header? is it just enough with the user and pass in the URL?


Yes, if you’re just using basic auth to connect to the server.


You can also checkout @jamiltz’s recent talk on building hybrid apps with Couchbase Lite:


thanks @zgramana the video helps us a lot but we still have doubts about basic auth. The slides/video shows the http request example schema for facebook and mentions place the user/pass into the URL.

Anyone has an example of the request for basic auth?
Anyone could tell us the step by step process for basic auth? For example:

  1. call Rest API /_session to get a validad session ID
  2. call Rest API /_replication with user/pass into the URL and session ID into the header.
  3. keep session ID until expires

In other hand, is there any repo for the video Todos example?
Thanks guys!


I already explained everything you need to do for Basic auth. You add the username and password to the remote DB URL. That’s it. Period. No need to use _session (I don’t believe we even implement _session in CBL’s REST API; it’s only in Sync Gateway.)