File tree Expand file tree Collapse file tree 6 files changed +11
-11
lines changed
code-snippets/authentication Expand file tree Collapse file tree 6 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1
1
const { MongoClient } = require ( "mongodb" ) ;
2
2
3
3
// Replace the following with values for your environment.
4
- const username = encodeURIComponent ( "<username >" ) ;
5
- const password = encodeURIComponent ( "<password >" ) ;
4
+ const username = encodeURIComponent ( "<db_username >" ) ;
5
+ const password = encodeURIComponent ( "<db_password >" ) ;
6
6
const clusterUrl = "<MongoDB cluster url>" ;
7
7
8
8
// Replace the following with your MongoDB deployment's connection string.
Original file line number Diff line number Diff line change 1
1
const { MongoClient } = require ( "mongodb" ) ;
2
2
3
3
// Replace the following with values for your environment.
4
- const username = encodeURIComponent ( "<username >" ) ;
5
- const password = encodeURIComponent ( "<password >" ) ;
4
+ const username = encodeURIComponent ( "<db_username >" ) ;
5
+ const password = encodeURIComponent ( "<db_password >" ) ;
6
6
const clusterUrl = "<MongoDB cluster url>" ;
7
7
8
8
const authMechanism = "DEFAULT" ;
Original file line number Diff line number Diff line change 1
1
const { MongoClient } = require ( "mongodb" ) ;
2
2
3
3
// Replace the following with values for your environment.
4
- const username = encodeURIComponent ( "<username >" ) ;
5
- const password = encodeURIComponent ( "<password >" ) ;
4
+ const username = encodeURIComponent ( "<db_username >" ) ;
5
+ const password = encodeURIComponent ( "<db_password >" ) ;
6
6
const clusterUrl = "<MongoDB cluster url>" ;
7
7
8
8
const authMechanism = "SCRAM-SHA-1" ;
Original file line number Diff line number Diff line change 1
1
const { MongoClient } = require ( "mongodb" ) ;
2
2
3
3
// Replace the following with values for your environment.
4
- const username = encodeURIComponent ( "<username >" ) ;
5
- const password = encodeURIComponent ( "<password >" ) ;
4
+ const username = encodeURIComponent ( "<db_username >" ) ;
5
+ const password = encodeURIComponent ( "<db_password >" ) ;
6
6
const clusterUrl = "<MongoDB cluster url>" ;
7
7
8
8
const authMechanism = "SCRAM-SHA-256" ;
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ database:
216
216
:copyable: true
217
217
218
218
const { MongoClient } = require("mongodb");
219
- const uri = "mongodb://<username >:<password >@<hostname>:<port>/?authSource=users";
219
+ const uri = "mongodb://<db_username >:<db_password >@<hostname>:<port>/?authSource=users";
220
220
const client = new MongoClient(uri);
221
221
222
222
You can check if this is the issue by attempting to connect to a MongoDB
Original file line number Diff line number Diff line change @@ -901,9 +901,9 @@ Authentication
901
901
902
902
.. code-block:: js
903
903
904
- new MongoClient("mongodb://username:password @<host><port>")
904
+ new MongoClient("mongodb://<db_username>:<db_password> @<host><port>")
905
905
// or
906
- new MongoClient(url, { auth: { username: "<>", password: "<>" } })
906
+ new MongoClient(url, { auth: { username: "<db_username >", password: "<db_password >" } })
907
907
908
908
``GridStore`` Removal
909
909
`````````````````````
You can’t perform that action at this time.
0 commit comments