OperationFailure: Ошибка аутентификации при вставке в коллекцию MongoDB, несмотря на правильные учетные данные
У меня есть база данных MongoDB, и я пытаюсь добавить кое-что из Colaboratory Notebook:
client = pymongo.MongoClient("mongodb+srv://test:<mypassjeje>@<unique identifier>.mongodb.net/<dbnamejojo>?retryWrites=true&w=majority")
db = client.test
fragrance = db.fragrance_db
Я заменил паролем для тестового пользователя и именем базы данных, которая будет использоваться подключениями по умолчанию.
Но когда я пытаюсь вставить что-то:
fragrance.insert_one(perfume)
Он возвращает:
---------------------------------------------------------------------------
OperationFailure Traceback (most recent call last)
<ipython-input-48-d831294ab74e> in <module>()
46 count += 1
47
---> 48 __main__()
19 frames
/usr/local/lib/python3.6/dist-packages/pymongo/helpers.py in _check_command_response(response, max_wire_version, msg, allowable_errors, parse_write_concern_error)
166 msg = msg or "%s"
167 raise OperationFailure(msg % errmsg, code, response,
--> 168 max_wire_version)
169
170
OperationFailure: bad auth : Authentication failed., full error: {'ok': 0, 'errmsg': 'bad auth : Authentication failed.', 'code': 8000, 'codeName': 'AtlasError'}
Я также пытаюсь с &authSource=admin в конце:
client = pymongo.MongoClient("mongodb+srv://test:<mypassjeje>@<unique identifier>.mongodb.net/<dbnamejojo>?retryWrites=true&w=majority&authSource=admin")
но он возвращает ту же ошибку:
OperationFailure: bad auth : Authentication failed., full error: {'ok': 0, 'errmsg': 'bad auth : Authentication failed.', 'code': 8000, 'codeName': 'AtlasError'}