title: How to configure authentication in MongoDB Java REST server?
body: <p>Just don't get where and how to put credentials in this framework</p>
  
  <p><a href="https://sites.google.com/site/mongodbjavarestserver/con" rel="nofollow">https://sites.google.com/site/mongodbjavarestserver/con</a></p>
  
  <p>I've set auth=true in mongoser.proeperties</p>
  
  <p>this is how auth.properties looks like:</p>
  
  <pre><code># use mongoreadonly realm for read only queries
  # use mongoreadwrite realm for read and write
  # use admin realm for read, write, delete, create
  
  reader: aaabbbccc, mongoreadonly
  writer: zzzxxxccc, mongoreadwrite
  admin: abcabcabc, admin
  </code></pre>
  
  <p>For now my MongoDB has Admin user "admin1" with password "pwd1" (which works with other clients fine).</p>
  
  <p>I've tried:</p>
  
  <pre><code>admin1: pwd1, admin
  </code></pre>
  
  <p>and</p>
  
  <pre><code>admin: pwd1, admin1
  </code></pre>
  
  <p>No success:</p>
  
  <pre><code>curl -i "http://myhosting.de:8081/query/test/abc"
  HTTP/1.1 401 Unauthorized
  WWW-Authenticate: basic realm="Mongodb Realm"
  Content-Length: 0
  </code></pre>
  
  <p>Any idea?</p>
  
  <p><strong>Update.</strong> I looks like auth=true secures REST API, but that is not what I am looking for. I was looking for how to connect to already secured Mongo DB.</p>
  
  <p>The new output message is:</p>
  
  <pre><code>{"status":"Mongodb: command failed [command failed [count] { \"serverUsed\" : \"127.0.0.1:27017\" , \"ok\" : 0.0 , \"errmsg\" : \"not authorized on test to execute command { count: \\\"abc\\\", query: {} }\" , \"code\" : 13}"}
  </code></pre>