-
Notifications
You must be signed in to change notification settings - Fork 72
Add auth to base examples #256
Comments
Thanks for the issue! user-password authentication occurs at the database-level. The user, password, and database are parsed from the URI, but I don't believe we have it set up to automatically authenticate when you create the database object, which is probably desirable from a user standpoint. |
Hi, I get:
I'm also not able to use '?' in the previous line were I connect 'with_uri'. What am I missing here? |
Sorry this is a year late, but for posterity, auth is on the db object. So try: let db = client.db("appdb")?;
db.auth("x", "y")?; You can only use let db = match client.db("appdb") {
Ok(db) => db,
Err(err) => /* Do something else */
};
if let Err(err) => db.auth("username", "password") {
eprintln!("Could not authenticate: {:?}", err)
} If all you want to do is exit the program when something fails, you can do: let db = client.database("appdb").expect("could not connect to database appdb");
db.auth("username", "password").expect("could not authenticate to database appdb"); |
Hello everyone! We've just released an alpha of an official MongoDB Rust driver; you can read about it here! Because of this, we won't be updating this driver anymore, and the repository will be made read-only as soon as I get finished posting these messages. Thanks for using this driver, and we hope you try out the new one! |
This might be common knowledge but I was not aware that there was the need for calling auth with user and password after already providing it via uri already.
So:
turned out to be
Is this a bug or am I missunderstanding user and pass in the uri ?
The text was updated successfully, but these errors were encountered: