title: Mongoengine - command find requires authentication
body: <p>I am new to using Mongoengine with an authenticated MongoDB.</p>
  
  <p>I have a Mongo Database called 'gambit_test'. I have enabled authentication on it and I have a proper user that can I authenticate into the database to perform read and write.</p>
  
  <p>I created the user for 'gambit_test' using the following command in Mongo Client:</p>
  
  <pre><code>use gambit_test
  db.createUser({
      user: "gambit_admin",
      pwd: "xxxxxx",
      roles:[{role: "userAdmin" , db:"admin"}]
  })
  </code></pre>
  
  <p>When I log into MongoDB to check my user status, I use a command as follows (logging in as a super admin):</p>
  
  <pre><code>mongo -u sup_admin -p yyyyyyyy
  </code></pre>
  
  <p>To verify my user status, here is what I run:</p>
  
  <pre><code>use gambit_test
  show users
  </code></pre>
  
  <p>It returns the following:</p>
  
  <pre><code>{
      "_id" : "gambit_test.gambit_admin",
      "user" : "gambit_admin",
      "db" : "gambit_test",
      "roles" : [
          {
              "role" : "readWrite",
              "db" : "gambit_test"
          },
          {
              "role" : "dbAdmin",
              "db" : "gambit_test"
          }
      ],
      "mechanisms" : [
          "SCRAM-SHA-1",
          "SCRAM-SHA-256"
      ]
  }
  </code></pre>
  
  <p>Inside my Python <code>test.py</code> code, here is what I am doing:</p>
  
  <pre><code>from mongoengine import *
  
  class History(Document):
      name = StringField(required=True)
  
  if __name__ == "__main__":
      try:
          connect('gambit_test')
          History.objects().get()
      except Exception as e: 
          connect(host='mongodb://gambit_admin:xxxxxx@localhost' + 
          ':27017/gambit_test')
          History.objects().get()
  </code></pre>
  
  <p>When I try to run the above python code, I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "test.py", line 12, in &lt;module&gt;
      History.objects().get()
    File "/home/ubuntu/gambit/genv/lib/python3.6/site-packages/mongoengine/queryset/base.py", line 267, in get
      result = six.next(queryset)
    File "/home/ubuntu/gambit/genv/lib/python3.6/site-packages/mongoengine/queryset/base.py", line 1484, in __next__
      raw_doc = six.next(self._cursor)
    File "/home/ubuntu/gambit/genv/lib/python3.6/site-packages/pymongo/cursor.py", line 1189, in next
      if len(self.__data) or self._refresh():
    File "/home/ubuntu/gambit/genv/lib/python3.6/site-packages/pymongo/cursor.py", line 1104, in _refresh
      self.__send_message(q)
    File "/home/ubuntu/gambit/genv/lib/python3.6/site-packages/pymongo/cursor.py", line 982, in __send_message
      helpers._check_command_response(first)
    File "/home/ubuntu/gambit/genv/lib/python3.6/site-packages/pymongo/helpers.py", line 155, in _check_command_response
      raise OperationFailure(msg % errmsg, code, response)
    pymongo.errors.OperationFailure: command find requires authentication
  </code></pre>
  
  <p>I have no clue why this is happening. The reason is I can perform normal find() and insert() using Mongo client. But, when I use Mongoengine, things break...</p>
  
  <p>Any help would be very much appreciated.</p>