Token Vending Machine - User Account Creation

76 views
Skip to first unread message

Derek Donnelly

unread,
Jan 20, 2014, 2:39:16 PM1/20/14
to mobile-c...@googlegroups.com
Hey Guys,

I'm building a mobile application in Android with Couchbase Lite and I've a question about Sync Gateway as it's quite new to be. The app talks to a Token Vending Machine and currently registers the user in a Amazon SimpleDB. I want to change this so that users are registered to my Couchbase database. The TVM itself is a Java project deployed as a war file in tomcat on the same server as my Couchbase database and Sync Gateway. In order to keep Sync Gateway happy, do I need to call though to the Sync Gateway Admin REST API on localhost from the Java code in the TVM or can/should I use the sdk (Couchbase Java Client Library 1.3) at this point given the context? It's a bit unclear to me reading the docs with this kind of setup.

Any help would be great appreciated.

Many thanks,

Derek.

Jens Alfke

unread,
Jan 20, 2014, 4:41:54 PM1/20/14
to mobile-c...@googlegroups.com
Hm, I'm not sure what aspect your question is focusing on. Are you asking about user registration and authentication, or about how your Java code can access the documents managed by the Sync Gateway?

If the question is authentication: The answer is to have the client communicate with your Java servlet to register, and then have the servlet call the Gateway's admin REST API to create a user account.

If you're asking about accessing documents: the best-supported mechanism for this currently is to use the Gateway's REST API, probably on the admin port so you can bypass authentication. We don't have good documentation of the API yet but it's basically a subset of CouchDB's, which is well-documented. It is also possible to interact directly with the underlying bucket using the Couchbase Server SDK, in limited ways: you can read documents as long as you ignore the "_sync" property and any documents whose keys begin with "_sync:". And you can create new documents as long as you set "importdocs":true in your database configuration.

—Jens

Derek Donnelly

unread,
Jan 20, 2014, 7:04:54 PM1/20/14
to mobile-c...@googlegroups.com
Sorry if my post was unclear. I was really just wondering about the initial user registration from the servlet, and if the servlet should do this via the gateway's admin REST APIs or is it okay to use the SDK, and if the latter would sync gateway get confused...

The answer is to have the client communicate with your Java servlet to register

It does.

 then have the servlet call the Gateway's admin REST API to create a user account. 

You've pretty much answered my question here. I just thought using the SDK might be preferred.

Thanks,

Derek.
Reply all
Reply to author
Forward
0 new messages