Unable to connect to cluster in vs code

Hi All, I am new to using mongodb and trying to connect to a database in vscode. I have tried connecting using langchain-mongodb package and pymongo both.
Python version- 3.11.1
Pymongo version - 4.12.1
langchain-mongodb - 0.6.1

code- Ping code from mongodb page itself.

from pymongo.mongo_client import MongoClient

uri = “mongodb+srv://srishtin:<my_password>@cluster0.uzk9vyc.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0”

  • i confirmed my password and username, its correct
  • also tried by adding authSource=admin

Create a new client and connect to the server

client = MongoClient(uri)

Send a ping to confirm a successful connection

try:
client.admin.command(‘ping’)
print(“Pinged your deployment. You successfully connected to MongoDB!”)
except Exception as e:
print(e)

I get bad auth error everytime.
While using langchain i get- ServerSelectionTimeoutError

Please let me know how to resolve the issue.
Thanks