Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 290

'Authentication Failed' Error using MongoDB OIDC

$
0
0

I am trying to connect to a MongoDB Atlas cluster via pymongo using the MongoDB-OIDC authentication method, with Azure as the identity provider.

I already setup the Azure provider and connected it to the Atlas org.

I have an Azure VM with a small python app to test this feature. Below is a code snippet from it:

def connect():    properties = {"ENVIRONMENT": "azure", "TOKEN_RESOURCE": "<AUDIENCE_URI>"}    client = MongoClient("<CONNECTION_STRING>",        username="<MANAGED_IDENTITY_CLIENT_ID>",        authMechanism="MONGODB-OIDC",        authMechanismProperties=properties    )    print("Created client")    try:        client.admin.command("ping")        print("Successfully pinged")    except Exception as e:        print(e)

However, I keep getting this Authentication failed error.

I've tried using both a system assigned and user assigned managed identity for the VM and also creating the corresponding database user in Atlas using their Client IDs but no luck yet.

Does anyone here have any experience with setting up MongoDB-OIDC with Azure? GCP was successfully setup using the documentation so not sure why Azure has been unsuccessful.

I described what I was expecting above.


Viewing all articles
Browse latest Browse all 290


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>