Skip to content

Commit ff1ba56

Browse files
authored
Authentication Usage Examples (#65)
1 parent cb7fbbe commit ff1ba56

File tree

6 files changed

+467
-10
lines changed

6 files changed

+467
-10
lines changed

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ toc_landing_pages = [
66
"/read",
77
"/connect",
88
"/indexes",
9+
"/security",
910
"/aggregation-tutorials",
1011
]
1112

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Sample Application
2+
~~~~~~~~~~~~~~~~~~
3+
4+
You can use the following sample application to test the code examples on this
5+
page. To use the sample application, perform the following steps:
6+
7+
1. Ensure you have {+driver-short+} installed.
8+
#. Copy the following code and paste it into a new ``.py`` file.
9+
#. Copy a code example from this page and paste it on the specified lines in the file.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# start sample app
2+
from pymongo import MongoClient
3+
4+
try:
5+
# start authentication code here
6+
7+
# end authentication code here
8+
9+
client.admin.command("ping")
10+
print("Authenticated successfully")
11+
12+
# other application code
13+
14+
client.close()
15+
16+
except Exception as e:
17+
raise Exception(
18+
"The following error occurred: ", e)
19+
# end sample app

0 commit comments

Comments
 (0)