Getting authentication error on stitch sdk for web

21 views
Skip to first unread message

Guilherme Guth

unread,
May 11, 2018, 12:37:36 PM5/11/18
to mongodb-user
Hi, I created an angular 6 app and using stitch javascript sdk to get some data of my mongodb database.

So I enabled annonymous authentication on stitch and copied the example code of the docs:


const clientPromise = stitch.StitchClientFactory.create('myappid');
clientPromise.then(client => {
const db = client.service('mongodb', 'mongodb-atlas').db('mydb-db');
client.login().then(() =>
db.collection('words').find({ owner_id: client.authedId() }).limit(100).execute()
).then(docs => {
console.log("Found docs", docs)
console.log("[MongoDB Stitch] Connected to Stitch")
}).catch(err => {
console.error(err)
});
}); 

But then im getting this error: 

main.js:404 Error: error connecting to MongoDB service cluster: unable to authenticate using mechanism "SCRAM-SHA-1": (AtlasError) bad auth Authentication failed.

What im missing here?

Thanks!

Wan Bachtiar

unread,
May 15, 2018, 3:06:21 AM5/15/18
to mongodb-user

What im missing here?

Hi Guilherme,

Looks like there is something off about the authentication. Check whether your myappid application has access to the database mydb-db.

If you’re still having difficulties connecting using Stitch, I would suggest to contact Cloud Support for Stitch and provide a sample application code.

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages