I have two databases (namely, test and celery). When a celery task is triggered, it will first update the "test" db with results and then update the "celery" db with success/failure message. I have secured these DBs with credentials and followed this method: https://medium.com/@matteocontrini/how-to-setup-auth-in-mongodb-3-0-properly-86b60aeef7e8
Now, when I run my task, it gives me this error:
pymongo.errors.OperationFailure: not authorized on celery to execute command { createIndexes: "celery_taskmeta", indexes: [ { key: { date_done: 1 }, background: "true", name: "date_done_1" } ] }
I am using: mongodb: 3.4 mongoengine: 0.16 django 2.1 and python3
mongoengine.connect(db="test",host=config.host,username="admin_1",
password="admin1234",authentication_source="admin")
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = "mongodb"
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
Apart from the method mentioned in the link above, I have tried creating an admin user in admin DB like this:
use admin
db.createUser(
{
user: "admin_1",
pwd: "admin1234",
roles: [
{
role: "dbOwner",
db: "test"
},
{
role: "userAdminAnyDatabase",
db: "admin"
},
{
role: "dbOwner",
db: "celery"
}
]
}
)
It gives the same error!