Not able to get client.list_database_names()

In “mongoclient” i have successfully get access of my cluster and also get result of “client.stats
But While i try to get database list using “client.list_database_names()” at that time it throw error : “OperationFailure: Authentication failed.”
here i have attached screen-shot of it.
Can any one help me out with it?
@kanikasingla can you please help me out in this too?

Please check the username password again to confirm as Authentication error is related to login credentials or authSource only.

Kanika

but the username and password are correct. and i got connection ticket also

The drivers don’t actually trigger any auth mechanism when you create a MongoClient but only when they actually begin performing operations.
This is desirable since you don’t want an idle driver to hold on to a connection (consume unnecessary resources) or start a needless connection.

So, please share the connection string you are using, it might be any special character or double quotes.

Kanika

this is the connection string that i am using
mongodb+srv://:@mflix-w5hgg.mongodb.net/test?retryWrites=true&w=majority

and i also try this one
mongodb+srv://:@mflix-w5hgg.mongodb.net/test

There are username and password missing. Please try using with username and password.
It should be something like this:

 mongodb+srv://<USERNAME>:<PASSWORD>@mflix-w5hgg.mongodb.net/test

Kanika

Yes, i know, i removed it to publish here.

Are you able to connect to your cluster from the terminal/command line? Make sure the IP is whitelisted.
As when I tried connecting to the cluster, I am not able to do so.

Kanika

yes, i did and run first “pytest -m connection” successfully.
but not able to run other test. I dont know why.

Hi @vishal_prajapati,

Please send the complete error report from jupyter notebook

1 Like