错误身份验证:身份验证失败。,完全错误:{'ok': 0, 'errmsg': '错误身份验证:身份验证失败。', 'code': 8000, 'codeName': 'Atla



我一直试图通过关注youtube视频来制作一个水准测量系统,当我完成代码时,它不断向我显示这个错误。我确保用户名和密码是正确的,但我可能会傻到错过其他东西。我有来自任何地方的白名单IP地址来访问数据库,我在heroku上托管机器人。

代码:

@commands.Cog.listener()
async def on_message(self,message):
cluster = MongoClient("mongodb+srv://<BitterDBAdmin>:<hidden>@bitterbotdb.zwiwd.mongodb.net/BitterBotDB?retryWrites=true&w=majority")
lvl_system = cluster["BitterLevelDB"]["Leveling_System"]
xp_channel = 942567995312582676
message_xp_range = random.randint(10,35)
if message.channel.id == xp_channel:
if not message.author.bot:
stats = lvl_system.find_one({"id":message.author.id})
if stats is None:
new_user = {"id":message.author.id, "xp": 0}
lvl_system.insert_one(new_user)
else:
xp = stats["xp"] + message_xp_range
lvl_system.update_one({"id": message.author.id},{"$set":{"xp":xp}})
lvl = 0
while True:
if xp < ((50*(lvl**2))+(50*(lvl-1))):
break
lvl += 1
xp -= ((50*(lvl**2))+(50*(lvl-1)))
if xp == 0:
await message.channel.send(f"{message.author.mention} reached **{lvl}**n*This feature is not completed.*")

错误:

File "C:Python310libsite-packagesnextcordclient.py", line 415, in _run_event
await coro(*args, **kwargs)
File "d:BitterVCSTest BotModulesLeveling Systemcodes.py", line 26, in on_message
stats = lvl_system.find_one({"id":message.author.id})
File "C:Python310libsite-packagespymongocollection.py", line 1114, in find_one
for result in cursor.limit(-1):
File "C:Python310libsite-packagespymongocursor.py", line 1159, in next
if len(self.__data) or self._refresh():
File "C:Python310libsite-packagespymongocursor.py", line 1080, in _refresh
self.__send_message(q)
File "C:Python310libsite-packagespymongocursor.py", line 971, in __send_message
response = client._run_operation(
File "C:Python310libsite-packagespymongomongo_client.py", line 1215, in _run_operation
return self._retryable_read(
File "C:Python310libsite-packagespymongomongo_client.py", line 1307, in _retryable_read
with self._secondaryok_for_server(read_pref, server, session) as (
File "C:Python310libcontextlib.py", line 135, in __enter__
return next(self.gen)
File "C:Python310libsite-packagespymongomongo_client.py", line 1162, in _secondaryok_for_server
with self._get_socket(server, session) as sock_info:
File "C:Python310libcontextlib.py", line 135, in __enter__
return next(self.gen)
File "C:Python310libsite-packagespymongomongo_client.py", line 1099, in _get_socket
with server.get_socket(
File "C:Python310libcontextlib.py", line 135, in __enter__
return next(self.gen)
File "C:Python310libsite-packagespymongopool.py", line 1371, in get_socket
sock_info = self._get_socket(all_credentials)
File "C:Python310libsite-packagespymongopool.py", line 1483, in _get_socket
sock_info = self.connect(all_credentials)
File "C:Python310libsite-packagespymongopool.py", line 1337, in connect
sock_info.check_auth(all_credentials)
File "C:Python310libsite-packagespymongopool.py", line 814, in check_auth
self.authenticate(credentials)
File "C:Python310libsite-packagespymongopool.py", line 831, in authenticate
auth.authenticate(credentials, self)
File "C:Python310libsite-packagespymongoauth.py", line 548, in authenticate
auth_func(credentials, sock_info)
File "C:Python310libsite-packagespymongoauth.py", line 469, in _authenticate_default
return _authenticate_scram(credentials, sock_info, 'SCRAM-SHA-1')
File "C:Python310libsite-packagespymongoauth.py", line 205, in _authenticate_scram
res = sock_info.command(source, cmd)
File "C:Python310libsite-packagespymongopool.py", line 719, in command
return command(self, dbname, spec, secondary_ok,
File "C:Python310libsite-packagespymongonetwork.py", line 158, in command
helpers._check_command_response(
File "C:Python310libsite-packagespymongohelpers.py", line 170, in _check_command_response
raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: bad auth : Authentication failed., full error: {'ok': 0, 'errmsg': 'bad auth : Authentication failed.', 'code': 8000, 'codeName': 'AtlasError'}

有什么办法解决这个问题吗?

我在输入用户名和密码时犯了一个非常常见的错误。我应该删除"<quot;以及">quot;in:

cluster = MongoClient("mongodb+srv://<BitterDBAdmin>:<hidden>@bitterbotdb.zwiwd.mongodb.net/BitterBotDB?retryWrites=true&w=majority")

来源:Mongodb+Atlas:';错误的身份验证身份验证失败';,代码:8000,

最新更新