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