@@ -222,59 +222,33 @@ implement a ``fetch()`` method, which returns the OIDC token in the form of an
222
222
223
223
The following example shows how to define a callback class named ``MyCallback``. This class
224
224
includes a ``fetch()`` method that retrieves an OIDC token from a file in the standard
225
- service-account token-file location. Select the :guilabel:`Synchronous` or
226
- :guilabel:`Asynchronous` tab to see the corresponding code:
225
+ service-account token-file location.
227
226
228
- .. tabs::
229
-
230
- .. tab:: Synchronous
231
- :tabid: sync
232
-
233
- .. literalinclude:: /includes/authentication/azure-envs-mongoclient.py
234
- :language: python
235
- :copyable: true
236
- :start-after: # define callback, properties, and MongoClient
237
- :end-before: properties = {"OIDC_CALLBACK": MyCallback()}
238
-
239
- .. tab:: Asynchronous
240
- :tabid: async
241
-
242
- .. literalinclude:: /includes/authentication/azure-envs-mongoclient-async.py
243
- :language: python
244
- :copyable: true
245
- :start-after: # define callback, properties, and MongoClient
246
- :end-before: properties = {"OIDC_CALLBACK": MyCallback()}
227
+ .. literalinclude:: /includes/authentication/azure-envs-mongoclient.py
228
+ :language: python
229
+ :copyable: true
230
+ :start-after: # define callback, properties, and MongoClient
231
+ :end-before: properties = {"OIDC_CALLBACK": MyCallback()}
247
232
248
233
After you define your callback class, create a Python dictionary that contains one key,
249
234
``"OIDC_CALLBACK"``, whose value is an instance of your custom callback class:
250
235
251
- .. tabs::
252
-
253
- .. tab:: Synchronous
254
- :tabid: sync
255
-
256
- .. literalinclude:: /includes/authentication/azure-envs-mongoclient.py
257
- :language: python
258
- :copyable: true
259
- :start-after: return OIDCCallbackResult(access_token=token)
260
- :end-before: client = MongoClient(
236
+ .. literalinclude:: /includes/authentication/azure-envs-mongoclient.py
237
+ :language: python
238
+ :copyable: true
239
+ :start-after: return OIDCCallbackResult(access_token=token)
240
+ :end-before: client = MongoClient(
261
241
262
- .. tab:: Asynchronous
263
- :tabid: async
264
-
265
- .. literalinclude:: /includes/authentication/azure-envs-mongoclient-async.py
266
- :language: python
267
- :copyable: true
268
- :start-after: return OIDCCallbackResult(access_token=token)
269
- :end-before: client = AsyncMongoClient(
270
-
271
- Finally, set the following connection options by passing arguments to the ``MongoClient``
272
- constructor:
242
+ Finally, set the following connection options by passing the followingarguments to the
243
+ ``MongoClient`` constructor:
273
244
274
245
- ``authMechanism``: Set to ``"MONGODB-OIDC"``.
275
246
- ``authMechanismProperties``: Set to the ``properties`` dictionary that you created in the
276
247
previous step.
277
248
249
+ Select the :guilabel:`Synchronous` or :guilabel:`Asynchronous` tab to see the corresponding
250
+ code:
251
+
278
252
.. tabs::
279
253
280
254
.. tab:: Synchronous
@@ -308,59 +282,33 @@ implement a ``fetch()`` method, which returns the OIDC token in the form of an
308
282
309
283
The following example shows how to define a callback class named ``MyCallback``. This class
310
284
includes a ``fetch()`` method that retrieves an OIDC token from a file in the standard
311
- service-account token-file location. Select the :guilabel:`Synchronous` or
312
- :guilabel:`Asynchronous` tab to see the corresponding code:
285
+ service-account token-file location.
313
286
314
- .. tabs::
315
-
316
- .. tab:: Synchronous
317
- :tabid: sync
318
-
319
- .. literalinclude:: /includes/authentication/gcp-gke-mongoclient.py
320
- :language: python
321
- :copyable: true
322
- :start-after: # define callback, properties, and MongoClient
323
- :end-before: properties = {"OIDC_CALLBACK": MyCallback()}
324
-
325
- .. tab:: Asynchronous
326
- :tabid: async
327
-
328
- .. literalinclude:: /includes/authentication/gcp-gke-mongoclient-async.py
329
- :language: python
330
- :copyable: true
331
- :start-after: # define callback, properties, and MongoClient
332
- :end-before: properties = {"OIDC_CALLBACK": MyCallback()}
287
+ .. literalinclude:: /includes/authentication/gcp-gke-mongoclient.py
288
+ :language: python
289
+ :copyable: true
290
+ :start-after: # define callback, properties, and MongoClient
291
+ :end-before: properties = {"OIDC_CALLBACK": MyCallback()}
333
292
334
293
After you define your callback class, create a Python dictionary that contains one key,
335
294
``"OIDC_CALLBACK"``, whose value is an instance of your custom callback class:
336
295
337
- .. tabs::
338
-
339
- .. tab:: Synchronous
340
- :tabid: sync
341
-
342
- .. literalinclude:: /includes/authentication/gcp-gke-mongoclient.py
343
- :language: python
344
- :copyable: true
345
- :start-after: return OIDCCallbackResult(access_token=token)
346
- :end-before: client = MongoClient(
296
+ .. literalinclude:: /includes/authentication/gcp-gke-mongoclient.py
297
+ :language: python
298
+ :copyable: true
299
+ :start-after: return OIDCCallbackResult(access_token=token)
300
+ :end-before: client = MongoClient(
347
301
348
- .. tab:: Asynchronous
349
- :tabid: async
350
-
351
- .. literalinclude:: /includes/authentication/gcp-gke-mongoclient-async.py
352
- :language: python
353
- :copyable: true
354
- :start-after: return OIDCCallbackResult(access_token=token)
355
- :end-before: client = AsyncMongoClient(
356
-
357
- Finally, set the following connection options by passing arguments to the ``MongoClient``
358
- constructor:
302
+ Finally, set the following connection options by passing the following arguments to the
303
+ ``MongoClient`` constructor:
359
304
360
305
- ``authMechanism``: Set to ``"MONGODB-OIDC"``.
361
306
- ``authMechanismProperties``: Set to the ``properties`` dictionary that you created
362
307
in the previous step.
363
308
309
+ Select the :guilabel:`Synchronous` or :guilabel:`Asynchronous` tab to see the corresponding
310
+ code:
311
+
364
312
.. tabs::
365
313
366
314
.. tab:: Synchronous
0 commit comments