Michael Lorton
Michael Lorton

Reputation: 44426

Connecting to an MongoDb from webpage anonymously — finding the DSN

I am trying to connect to MongDB via Atlas Realm from a web-page. The instructions, of course, make it look easy, saying you should do this:

const mongo = app.currentUser.mongoClient(DATA_SOURCE_NAME);

They just don’t tell you want your Datasource name is.

Much futzing around suggested I could use the following as an DSN:

mongodb://_:${apiKey}@us-west-2.aws.realm.mongodb.com:27020/?authMechanism=PLAIN&authSource=%24external&ssl=true&appName=my-app-name:mongodb-atlas:api-key

All I need know is the api-key. Even more futzing around suggested I could use the following:

const apiKey = await user.apiKeys.create("abc");

But that gives me a 403.

Obviously, if I cannot use Mongo to retrieve data, it’s not very useful...

Upvotes: 0

Views: 163

Answers (0)

Related Questions