def _authenticate_mongo_cr(credentials, sock_info):
 source = credentials.source
 username = credentials.username
 password = credentials.password
 response = sock_info.command(source, {'getnonce': 1})
 nonce = response['nonce']
 key = _auth_key(nonce, username, password)
 query = SON([('authenticate', 1), ('user', username), ('nonce', nonce), ('key', key)])
 sock_info.command(source, query)

def _authenticate_mongo_cr ( credentials , sock_info ) : source = credentials . source username = credentials . username password = credentials . password response = sock_info . command ( source , { 'getnonce' : 1 } ) nonce = response [ 'nonce' ] key = _auth_key ( nonce , username , password ) query = SON ( [ ( 'authenticate' , 1 ) , ( 'user' , username ) , ( 'nonce' , nonce ) , ( 'key' , key ) ] ) sock_info . command ( source , query )
authenticate using mongodb-cr .