Couchbase bucket with password is not working in couchbase server 4.0


#1

I am using couch base server 4.0 community Edition

Issue: Couch base bucket with password is not working means i could not able to access in couch base server 4.0


#2

Hi there,
Are you setting the password when initializing couchbase configuration?

web.config

<couchbase>
<servers>
        <add uri="http://xxx.xxx.xxx.xxx:8091/pools" />
      </servers>
      <buckets>
        <add name="xxxx" password="????" />
</buckets>
</couchbase>

OU

IN CODE
_bucket = _cluster.OpenBucket(CouchbaseBucket, CouchbaseBucketPassword);


#4

Hi Rafael,

Thanks for your reply

My web.config

<couchbase Bucket="bucketName" BucketPassword="????" CacheKeyPrefix="prefix">
  <Servers>
    <Server Host="http://xxx.xxx.xxx.xxx:8091/pools" />
  </Servers>
  <Pool MinSize="2" MaxSize="5" />
</couchbase >

#5

Thank you Rafael its working.

one more question how to used bucket password with N1QL query


#6

In the Java client the Bucket object from which you call query() are automatically added to the HTTP request headers.

But I think in the .NET client, the credentials are expected to be injected in the request body for the query service to consume, via QueryRequest.AddCredentials.

The problem is there is a bug in 4.0/4.1 that fails to take these credentials into account :bug: :frowning:
See MB-16964.

@jmorris do you know about a workaround for that particular problem?


#7

@balaji.j @rafael.felix @simonbasle -

QueryRequest.AddCredentials won’t work until MB-16964 is fixed on the server, however the workaround is to just use the bucket credentials and limit your query scope to the bucket you are authenticated against:


So, basically this:

bucket = _cluster.OpenBucket("mybucket", CouchbaseBucketPassword);
var result = bucket.Query(new QueryRequest("SELECT * FROM `mybucket`;"));

is all you need to do to query against an authenticated bucket assuming your client version >= 2.2.4.

-Jeff


#8

Its working fine :slight_smile: Thank you