@@ -33,7 +33,7 @@ the driver attempts to authenticate using ``MONGODB-CR``.
3333
3434You can specify this authentication mechanism by setting the ``authMechanism``
3535parameter to ``DEFAULT`` in the
36- :manual:`URI ConnectionString </reference/connection-string/>`, or by omitting
36+ :manual:`connection string </reference/connection-string/>`, or by omitting
3737the parameter since it is the default value. Also include your username and
3838password as shown in the code below.
3939
@@ -63,9 +63,13 @@ algorithm to authenticate your user.
6363
6464You can specify this authentication mechanism by setting the ``authMechanism``
6565to the value ``SCRAM-SHA-256`` in the
66- :manual:`URI ConnectionString </ reference/connection-string/>` as shown in the
66+ :manual:`connection string < reference/connection-string/>` as shown in the
6767following sample code.
6868
69+ .. important::
70+ Always **URI encode** the username and password using the
71+ ``encodeURIComponent`` method to ensure they are correctly parsed.
72+
6973.. literalinclude:: /code-snippets/authentication/sha256.js
7074 :language: javascript
7175 :dedent: 4
@@ -83,9 +87,13 @@ your user.
8387
8488You can specify this authentication mechanism by setting the ``authMechanism``
8589parameter to the value ``SCRAM-SHA-1`` in the
86- :manual:`URI ConnectionString </reference/connection-string/>` as shown
90+ :manual:`connection string </reference/connection-string/>` as shown
8791in the following sample code.
8892
93+ .. important::
94+ Always **URI encode** the username and password using the
95+ ``encodeURIComponent`` method to ensure they are correctly parsed.
96+
8997.. literalinclude:: /code-snippets/authentication/sha1.js
9098 :language: javascript
9199 :dedent: 4
@@ -101,9 +109,13 @@ username and password to authenticate your user.
101109
102110You can specify this option by setting the ``authMechanism`` parameter to value
103111``MONGODB-CR`` in the
104- :manual:`URI ConnectionString </reference/connection-string/>` as shown
112+ :manual:`connection string </reference/connection-string/>` as shown
105113in the following sample code.
106114
115+ .. important::
116+ Always **URI encode** the username and password using the
117+ ``encodeURIComponent`` method to ensure they are correctly parsed.
118+
107119.. literalinclude:: /code-snippets/authentication/cr.js
108120 :language: javascript
109121 :dedent: 4
@@ -129,14 +141,18 @@ the X.509 certificate, see the MongoDB manual :manual:`X.509 tutorial
129141
130142You can specify this authentication mechanism by setting the following
131143parameters of your
132- :manual:`URI ConnectionString </reference/connection-string/>`:
144+ :manual:`connection string </reference/connection-string/>`:
133145
134146- Set the ``authMechanism`` parameter to the value ``MONGODB-X509``
135147- Set the ``tls`` parameter to the value ``true``
136148
137149Pass the location of your client certificate file as the value of
138150``tlsCertificateKeyFile`` as a parameter of the connection URI.
139151
152+ .. important::
153+ Always **URI encode** the username and certificate file path using the
154+ ``encodeURIComponent`` method to ensure they are correctly parsed.
155+
140156.. literalinclude:: /code-snippets/authentication/x509.js
141157 :language: javascript
142158 :dedent: 4
0 commit comments