@@ -408,8 +408,10 @@ Azure IMDS
408
408
^^^^^^^^^^
409
409
410
410
For an application running on an Azure VM or otherwise using the `Azure Internal Metadata Service `_,
411
- you can use the built-in support for Azure, where "<client_id>" below is the client id of the Azure
412
- managed identity, and ``<audience> `` is the url-encoded ``audience `` `configured on your MongoDB deployment `_.
411
+ you can use the built-in support for Azure. If using an Azure managed identity, the "<client_id>" is
412
+ the client ID. If using a service principal to represent an enterprise application, the "<client_id>" is
413
+ the application ID of the service principal. The ``<audience> `` value is the ``audience ``
414
+ `configured on your MongoDB deployment `_.
413
415
414
416
.. code-block :: python
415
417
@@ -430,11 +432,24 @@ managed identity, and ``<audience>`` is the url-encoded ``audience`` `configured
430
432
If the application is running on an Azure VM and only one managed identity is associated with the
431
433
VM, ``username `` can be omitted.
432
434
435
+ If providing the ``TOKEN_RESOURCE `` as part of a connection string, it can be given as follows.
436
+ If the ``TOKEN_RESOURCE `` contains any of the following characters [``, ``, ``+ ``, ``& ``], then
437
+ it MUST be url-encoded.
438
+
439
+ .. code-block :: python
440
+
441
+ import os
442
+
443
+ uri = f ' { os.environ[" MONGODB_URI" ]} ?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:azure,TOKEN_RESOURCE:<audience> '
444
+ c = MongoClient(uri)
445
+ c.test.test.insert_one({})
446
+ c.close()
447
+
433
448
GCP IMDS
434
449
^^^^^^^^
435
450
436
451
For an application running on an GCP VM or otherwise using the `GCP Internal Metadata Service `_,
437
- you can use the built-in support for GCP, where ``<audience> `` below is the url-encoded ``audience ``
452
+ you can use the built-in support for GCP, where ``<audience> `` below is the ``audience ``
438
453
`configured on your MongoDB deployment `_.
439
454
440
455
.. code-block :: python
@@ -448,6 +463,18 @@ you can use the built-in support for GCP, where ``<audience>`` below is the url-
448
463
c.test.test.insert_one({})
449
464
c.close()
450
465
466
+ If providing the ``TOKEN_RESOURCE `` as part of a connection string, it can be given as follows.
467
+ If the ``TOKEN_RESOURCE `` contains any of the following characters [``, ``, ``+ ``, ``& ``], then
468
+ it MUST be url-encoded.
469
+
470
+ .. code-block :: python
471
+
472
+ import os
473
+
474
+ uri = f ' { os.environ[" MONGODB_URI" ]} ?authMechanism=MONGODB-OIDC&authMechanismProperties=ENVIRONMENT:gcp,TOKEN_RESOURCE:<audience> '
475
+ c = MongoClient(uri)
476
+ c.test.test.insert_one({})
477
+ c.close()
451
478
452
479
Custom Callbacks
453
480
~~~~~~~~~~~~~~~~
0 commit comments