Testing for authentication

With the .NET library, I am using the AuthenticatorFactory ritual to the push and pull methods.

What is the method/property that confirms whether or not the user is authenticated? Or do I have to do some REST thing to see if the user really exists or not?

Mobile folks may be able to help here @borrrden.


If the user is not properly authenticated then replication will fail and the error will be 403 (Unauthorized). What kind of authentication are you using?

Just the typical user authentication with the admin port, not Facebook or
the others. I realize that replication will fail, but in the case of a new
user, there is nothing to replicate. So initially there would be no
"error". So as the user starts adding documents to the local database,
nothing is replicated to the server.

I have no way of knowing if the credentials are valid (using the NET
libraries that you supply) except if there is an error? That is really not
a good user experience if they have to wait until they add a document -
then we popup “you are not a valid user”. I should know when they do the
login credentials if that are valid.


Well, there is no way to know without actually sending an HTTP request. One thing you could do is send an HTTP request to the database URL using the credentials you got and look at the HTTP response. The replication will not send any requests until it has something to send in the case of a push. For a pull, it will fail more quickly because it will attempt to ask for existing documents and fail at that point.

@jens Is there any other available method to quickly check using API calls?

I’m confused. Is this a server-side question (it’s in a server forum) or is it about Couchbase Lite?

First of all we are in the .NET SDK forum. It is a Couchbase Lite/Sync Gateway issue. Since there is a SDK for authentication and syncing, it just seems that we should be able to “ask” if it authenticated or not. Doing a HTTP request is doable, (I think!) but it seems with a SDK we shouldn’t have to do HTTP requests.

@jeffh -

Part the confusion here is that this is the .NET SDK Forum - for the Server client: http://developer.couchbase.com/documentation/server/4.0/sdks/dotnet-2.2/dotnet-intro.html

Couchbase Lite .NET library is a different API with a different forum - https://www.couchbase.com/forums/c/mobile

@jens - his question pertains to Mobile auth via Couchbase Lite .NET library.



Note, I’ve moved this to the proper category: Mobile/Couchbase Lite.

1 Like