mongodb / flask-pymongo

PyMongo support for Flask applications
BSD 2-Clause "Simplified" License
721 stars 175 forks source link

Better authentication documentation? #142

Open UNIcodeX opened 4 years ago

UNIcodeX commented 4 years ago

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}"

dcrosta commented 4 years ago

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.