title: Authentication in mongodb python
body: <p>I am trying to connect to a mongodb database using authentication. My code for doing so is the following:</p>
  
  <pre><code>from pymongo import MongoClient
  import urllib
  client = MongoClient()
  client = MongoClient('ip', port)
  client.prod_db.authenticate('username', 'pass',  source='source_database')
  </code></pre>
  
  <p>However I am receiving the following error in the authentication line:</p>
  
  <blockquote>
    <p>pymongo.errors.OperationFailure: Authentication failed.</p>
  </blockquote>
  
  <p>Am I doing the whole authentication thing wrongly?</p>
  
  <p><strong>EDIT:</strong> Also tried to use the following schema:</p>
  
  <pre><code>client = MongoClient('mongodb://user:pass@ip:port/')
  </code></pre>
  
  <p>And I received the same mistake.</p>