A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mongodb.com/docs/languages/python/pymongo-driver/current/security/authentication/scram/ below:

SCRAM - PyMongo Driver v4.13

Salted Challenge Response Authentication Mechanism (SCRAM) is a family of authentication mechanisms that use a challenge-response mechanism to authenticate the user. SCRAM-SHA-256, which uses the SHA-256 algorithm to hash your password, is the default authentication mechanism in MongoDB Server version 4.0 and later. SCRAM-SHA-1, which uses the SHA-1 algorithm instead, is the default authentication mechanism in MongoDB Server versions earlier than 4.0.

You can use SCRAM to authenticate to MongoDB Atlas, MongoDB Enterprise Advanced, and MongoDB Community Edition.

The code examples on this page use the following placeholders:

To use the code examples on this page, replace these placeholders with your own values.

Important Percent-Encoding

You must percent-encode a username and password before you include them in a MongoDB URI. The quote_plus() method, available in the urllib.parse module, is one way to perform this task. For example, calling quote_plus("and / or") returns the string and+%2F+or.

Don't percent-encode the username or password when passing them as arguments to MongoClient.

To use SCRAM to authenticate, set the authMechanism connection option to SCRAM-SHA-1 or SCRAM-SHA-256. You can set this option in two ways: by passing an argument to the MongoClient constructor or through a parameter in your connection string.

client = pymongo.MongoClient("mongodb[+srv]://<hostname>:<port>",                             username="<db_username>",                             password="<db_password>",                             authSource="<authenticationDb>",                             authMechanism="<authenticationMechanism>")
uri = ("mongodb[+srv]://<percent-encoded db_username>:<percent-encoded db_password>"       "@<hostname>:<port>/?"       "authSource=<authenticationDb>"       "&authMechanism=<authenticationMechanism>")client = pymongo.MongoClient(uri)
client = pymongo.AsyncMongoClient("mongodb[+srv]://<hostname>:<port>",                                  username="<db_username>",                                  password="<db_password>",                                  authSource="<authenticationDb>",                                  authMechanism="<authenticationMechanism>")
uri = ("mongodb[+srv]://<percent-encoded db_username>:<percent-encoded db_password>"       "@<hostname>:<port>/?"       "authSource=<authenticationDb>"       "&authMechanism=<authenticationMechanism>")client = pymongo.AsyncMongoClient(uri)

To learn more about authenticating your application in PyMongo, see the following API documentation:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4