Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pymongo.errors.OperationFailure: TxMongo: not authorized for query on foo.test #287

Open
ma-pony opened this issue May 11, 2023 · 1 comment

Comments

@ma-pony
Copy link

ma-pony commented May 11, 2023

When I connect to MongoDB using my username password, it throws an error not authorized, is there a configuration problem?

env:

docker run --name mongo-4.2.0 -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=username -e MONGO_INITDB_ROOT_PASSWORD=password --restart always -d mongo:4.2.0

Platform macOS-13.3.1-arm64-arm-64bit
Python 3.10.8

MongoDB 4.2.0

twisted==21.7.0
txmongo==23.0.0
pymongo==3.13.0 

code:

from twisted.internet import defer, reactor
from txmongo.connection import ConnectionPool


@defer.inlineCallbacks
def example():
    mongodb_uri = "mongodb://username:[email protected]:27017/?authMechanism=DEFAULT"

    mongo = yield ConnectionPool(mongodb_uri)

    foo = mongo.foo  # `foo` database
    test = foo.test  # `test` collection

    # fetch some documents
    docs = yield test.find(limit=10)
    for doc in docs:
        print(doc)


if __name__ == '__main__':
    example().addCallback(lambda ign: reactor.stop())
    example().addErrback(lambda ign: reactor.stop())
    reactor.run()

@ma-pony
Copy link
Author

ma-pony commented May 12, 2023

image
MongoDB 4.0 and later default sha256 mec,txmongo doesn't seem to support this option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant