def _authenticate_plain(credentials, sock_info):
 source = credentials.source
 username = credentials.username
 password = credentials.password
 payload = ('\x00%s\x00%s' % (username, password)).encode('utf-8')
 cmd = SON([('saslStart', 1), ('mechanism', 'PLAIN'), ('payload', Binary(payload)), ('autoAuthorize', 1)])
 sock_info.command(source, cmd)

def _authenticate_plain ( credentials , sock_info ) : source = credentials . source username = credentials . username password = credentials . password payload = ( '\x00%s\x00%s' % ( username , password ) ) . encode ( 'utf-8' ) cmd = SON ( [ ( 'saslStart' , 1 ) , ( 'mechanism' , 'PLAIN' ) , ( 'payload' , Binary ( payload ) ) , ( 'autoAuthorize' , 1 ) ] ) sock_info . command ( source , cmd )
authenticate using sasl plain .