title: how can i validate username password for mongodb authentication through pymongo?
body: <p>I am refering to the <a href="http://api.mongodb.org/python/current/examples/authentication.html" rel="noreferrer">http://api.mongodb.org/python/current/examples/authentication.html</a> site for authentication mechanism examples. I have created a User administrator and using its credentials I created a user for my 'reporting' database. Now i need to access the same through pymongo using the username and password. I tried the following commands in python shell. Is this the right way as my authentication is failing.</p>
  
  <pre><code>from pymongo import MongoClient
  
  client = MongoClient('localhost')
  
  client.reporting.authenticate('reportsUser', '123456', mechanism='MONGODB-CR')
  
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python2.7/dist-packages/pymongo/database.py", line 746, in authenticate
      self.connection._cache_credentials(self.name, credentials)
    File "/usr/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 441, in _cache_credentials
      auth.authenticate(credentials, sock_info, self.__simple_command)
    File "/usr/lib/python2.7/dist-packages/pymongo/auth.py", line 214, in authenticate
      auth_func(credentials[1:], sock_info, cmd_func)
    File "/usr/lib/python2.7/dist-packages/pymongo/auth.py", line 194, in _authenticate_mongo_cr
      cmd_func(sock_info, source, query)
    File "/usr/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 607, in __simple_command
      helpers._check_command_response(response, None, msg)
    File "/usr/lib/python2.7/dist-packages/pymongo/helpers.py", line 147, in _check_command_response
      raise OperationFailure(msg % errmsg, code)
  pymongo.errors.OperationFailure: command SON([('authenticate', 1), ('user', u'reportsUser'), ('nonce', u'f8158a24f1c61650'), ('key', u'14cea216c54b93bae20acd2e076bb785')]) failed: auth failed
  </code></pre>