CouchbaseError: Authentication failed

I’m getting the following error on an AWS environment:

app err { [CouchbaseError: Authentication failed. You may have provided an invalid username/password combination] message: 'Authentication failed. You may have provided an invalid username/password combination', code: 2 } +2s

I’m not experiencing the same issue on my local environment. The main difference between my local environment and AWS is that my local is running 3.x and AWS has 4.x.

Here’s my code:

var cluster = new couchbase.Cluster('sampleHostname:port'); var counterBucket = cluster.openBucket('sampleBucketName', 'samplePassword');

I’m supplying the same password as my CB login.

Any suggestions how to resolve this?

Adrian

Hey @agillette,
It looks like you are passing your Couchbase Administrator password to the openBucket method. You should actually pass the bucket password itself which is specified through the Couchbase Administration UI. This defaults to a blank password usually.
Cheers, Brett

Thanks @brett19 for the suggestion. That did the trick.

Adrian

Hey guys,

Since I have the same “Authentication failed” problem I didn’t create a new topic but I reply here hoping someone can help me.

The error is the same that @agillette had, but in my case I dont have a password for the bucket, instead I have a password fro the whole Cluster, that is the same I use to login in the Administration panel.

Where do I have to put username and password ? I tried everything, I put it in the connection string in the Cluster constructor, I tried to to add username and password as second parameter of the Cluster object, but it didn’t work.

In all examples online they always use only this line of code

var cluster = new couchbase.Cluster(‘couchbase://127.0.0.1’);

But in my case the cluster isn’t located in localhost and I need to provide username and password in addiction to the host.

Could you help me please?

Alessandro

not sure about the cluster password but I solved my authentication problem as follows

ran the following on the machine running couchbase
$ curl -u AdminName:AdminPass http://localhost:8091/pools/default/buckets

and found the key saslPassword, copied and provided it to
cluster.openBucket("bucketname", "SASLPASSWORD")

et voilá :smiley:

hope it helps someone

can

I used @Can suggested approach and it solved my problem.
now my question is:
What is the concept of SASL password in couchbase.
can I use in real world projects? (I mean is that secure to use it in code?)

Just treat the password like you would any other. Keep it encrypted if you need to keep it with the app, or store it somewhere else (like Azure Key Vault) and only let authorised applications retrieve it.

There were a lot of improvements in Couchbase 5.x for security, and you can have really granular permissions now for different user accounts.