Hello,
I am been trying to connect with MONGODB-AWS authMechanism which uses $external as virtual database for authSource and I keep getting this error: “Invalid character $ in database name: $external”
Could someone please help?
Hello,
I am been trying to connect with MONGODB-AWS authMechanism which uses $external as virtual database for authSource and I keep getting this error: “Invalid character $ in database name: $external”
Could someone please help?
A connection string will have to url encode many special characters. Replacing $
with %24
should be enough to get you connected.
If you have mongodb compass you cana use the advanced options to set many parameters and the copy the resulting connection string to where you need it.
Hello @chris,
Error is the same. Invalid character even with %24 encoding.
Error stack trace:
Database error (MongoSecurityException): Exception authenticating MongoCredential{mechanism=MONGODB-AWS, userName='<accessKeyId>', source='$external', password=<hidden>, mechanismProperties=<hidden>}
Stacktrace:
|_/ Database error (MongoSecurityException): Exception authenticating MongoCredential{mechanism=MONGODB-AWS, userName='<accessKeyId>', source='$external', password=<hidden>, mechanismProperties=<hidden>}
|____/ Mongo Server error (MongoCommandException): Command failed with error 73: 'Invalid character $ in database name: $external' on server <docdb-cluster-endpoint>:27017.
|____...
|____... The full response is:
|____... {
|____... "ok" : 0.0,
|____... "code" : 73.0,
|____... "errmsg" : "Invalid character $ in database name: $external",
|____... "operationTime" : Timestamp(1692643307, 1)
|____... }
What driver are you using?
Can you paste the redacted connection string your are using?
Hello @chris,
I tried connecting via Compass, Studio3T and even PyMongo. Error is consistent.
FYI - It’s a DocumentDB Cluster Endpoint and I am trying to authenticate with “MONGODB-AWS” mechanism of assuming role with STS credentials.
Maybe “MONGODB-AWS” mechanism is only configured and supported for Mongodb Atlas clusters?
Connection String:
client = pymongo.MongoClient('mongodb://%s:%s@docdb-xxx.us-east-1.docdb.amazonaws.com/?authMechanism=MONGODB-AWS&authMechanismProperties=AWS_SESSION_TOKEN:%s&tls=true&tlsCAFile=./src/global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false' % (accesskeyid,secretkey,sessiontoken))
I get the following error upon connecting to the client or finding documents in a collection.
Error:
pymongo.errors.OperationFailure: Invalid character $ in database name: $external, full error: {'ok': 0.0, 'code': 73, 'errmsg': 'Invalid character $ in database name: $external', 'operationTime': Timestamp(1692723661, 1)}
Its not MongoDB, it is not MongoDB Atlas, so that is certainly the issue.
Thank you @chris for confirming.
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.