Another solution-
I created a SCRAM user in the database access tab.
Then, I added &authSource=the_database&authMechanism=SCRAM-SHA-1 to the connection string. Like this:
connect_string = 'mongodb+srv://{}:{}@{}/?retryWrites=true&authSource=the_database&authMechanism=SCRAM-SHA-1'.format(username, password, hostname)
py_client = MongoClient(connect_string)