Skip to content

Commit 3279d03

Browse files
committed
PYTHON-1052 - Clarify delegated auth example
1 parent 49c847f commit 3279d03

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

doc/examples/authentication.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,20 @@ Delegated Authentication
6666
------------------------
6767
.. versionadded: 2.5
6868
69-
In MongoDB 2.4.x a separate authentication source can be specified.
70-
This feature was introduced in MongoDB 2.4 and removed in 2.6::
69+
If your user is defined in one database with a role that gives it
70+
authorization on a different database use the `source` option to specify
71+
the database in which the user is defined::
7172

7273
>>> from pymongo import MongoClient
7374
>>> client = MongoClient('example.com')
74-
>>> client.the_database.authenticate('user',
75-
... 'password',
76-
... source='source_database')
75+
>>> db = client.the_database
76+
>>> db.authenticate('user', 'password', source='source_database')
7777
True
78-
>>>
78+
79+
Or the `authSource` URI option::
80+
7981
>>> uri = "mongodb://user:password@example.com/?authSource=source_database"
80-
>>> client = MongoClient(uri)
81-
>>>
82+
>>> db = MongoClient(uri).the_database
8283

8384
MONGODB-X509
8485
------------

0 commit comments

Comments
 (0)