flask-pymongo icon indicating copy to clipboard operation
flask-pymongo copied to clipboard

Better authentication documentation?

Open UNIcodeX opened this issue 5 years ago • 1 comments

After nearly 2 hours trying to figure out how to get authentication working with this module, the solution was finally realized, that when using authentication, merely passing the connection string as the following was not sufficient.

app.config["MONGO_URI"] = "mongodb://{username}:{password}@{uri}:{port}/{db_name}"

Instead, one must apparently also pass an authSource parameter like so: app.config["MONGO_URI"] = "mongodb://{username}:{password}@{uri}:{port}/{db_name}?authSource={authSource}"

UNIcodeX avatar Jun 01 '20 04:06 UNIcodeX

Sorry to hear that -- it must be frustrating. I'd welcome a change to the docs to make this clearer. The important point to emphasize is that we pass the connection URI directly to PyMongo, so all behavior about interpretation of the connection string is determined by PyMongo itself. If you'd like to update the docs, please do include a link to https://pymongo.readthedocs.io/en/stable/examples/authentication.html which has examples and details about the behavior.

dcrosta avatar Jun 02 '20 11:06 dcrosta