Sync Gateway authentication error

We are having following configuration working perfectly
Server : 5.1
Sync Gateway : 2.0
CBL(Android) : 1.5

Now We are trying to switch to cbl 2.0 so I changed Sync URL to
wss://devsync.dirolabs.com/phonebooks
instead of https://devsync.dirolabs.com/phonebooks

and we started getting following error in the logs

05-21 12:40:49.844 13418-13554/com.diro E/LiteCore [Sync]: {Repl#1}==> N8litecore4repl10ReplicatorE /data/user/0/com.diro/files/ghost.cblite2/ ->wss:devsync.dirolabs.com/phonebooks/_blipsync
{Repl#1} Got LiteCore error: Unauthorized (6/401)
05-21 12:40:55.148 13418-13556/com.diro E/LiteCore [Sync]: {Repl#2}==> N8litecore4repl10ReplicatorE /data/user/0/com.diro/files/diro.cblite2/ ->wss:devsync.dirolabs.com/phonebooks/_blipsync
{Repl#2} Got LiteCore error: Unauthorized (6/401)

I am not able to figure out the error. Can some body help me out??

Are you using the basic authentication ? If yes then would like you to know that the authenticationfactory doesn’t work on 2.0. And you need to use specific authentication.

Can you share your syncgateway configuration also.

We are using basic account Authenticator as provided in cbl2.0 docs i.e.

// Add authentication.
replConfig.setAuthenticator(new BasicAuthenticator("john", "pass"));

Sync gateway config file is

https://drive.google.com/file/d/10iRTl5BEpWtEW0oE6uDl8CQ_E_-cikXD/view?usp=sharing

I am getting following response

05-21 14:58:47.825 3508-3987/com.diro W/WS: WebSocketListener.onFailure() response -> Response{protocol=http/1.1, code=401, message=Unauthorized, url=https://devsync.dirolabs.com/phonebooks/_blipsync}
    java.net.ProtocolException: Expected HTTP 101 response but was '401 Unauthorized'
        at okhttp3.internal.ws.RealWebSocket.checkResponse(RealWebSocket.java:219)
        at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:186)
        at com.newrelic.agent.android.instrumentation.okhttp3.CallbackExtension.onResponse(CallbackExtension.java:40)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)

05-21 14:58:42.913 3508-3986/com.diro W/LiteCore [WS]: {N8litecore9websocket12C4SocketImplE#1}==> N8litecore9websocket12C4SocketImplE wss:devsync.dirolabs.com/phonebooks/_blipsync
    {N8litecore9websocket12C4SocketImplE#1} WebSocket closed abnormally with status 401
05-21 14:58:42.913 3508-3966/com.diro E/LiteCore [Sync]: {Repl#1}==> N8litecore4repl10ReplicatorE /data/user/0/com.diro/files/diro.cblite2/ ->wss:devsync.dirolabs.com/phonebooks/_blipsync
    {Repl#1} Got LiteCore error: Unauthorized (6/401)

The user doesn’t appear to be configured in your Sync Gateway. Make sure your configure the list of valid users in the configuration file or use the user REST API to add the user.

Once users are added, you can dynamically give access to users via channels/access APIs.

An example configuration file for reference

Yes you are right,

I figured it out. The problem is now fixed