def _try_auth(self):
if self.authenticated:<EOL><INDENT>self.__logger.debug("<STR_LIT>")<EOL>return<EOL><DEDENT>self.__logger.debug("<STR_LIT>" % (self._auth_methods_left,))<EOL>if not self._auth_methods_left:<EOL><INDENT>raise LegacyAuthenticationError("<STR_LIT>")<EOL><DEDENT>method=self._auth_methods_left[<NUM_LIT:0>]<EOL>if method.startswith("<STR_LIT>"):<EOL><INDENT>return ClientStream._try_auth(self)<EOL><DEDENT>elif method not in ("<STR_LIT>","<STR_LIT>"):<EOL><INDENT>self._auth_methods_left.pop(<NUM_LIT:0>)<EOL>self.__logger.debug("<STR_LIT>" % method)<EOL>return self._try_auth()<EOL><DEDENT>elif self.available_auth_methods is not None:<EOL><INDENT>if method in self.available_auth_methods:<EOL><INDENT>self._auth_methods_left.pop(<NUM_LIT:0>)<EOL>self.auth_method_used=method<EOL>if method=="<STR_LIT>":<EOL><INDENT>self._digest_auth_stage2(self.auth_stanza)<EOL><DEDENT>else:<EOL><INDENT>self._plain_auth_stage2(self.auth_stanza)<EOL><DEDENT>self.auth_stanza=None<EOL>return<EOL><DEDENT>else:<EOL><INDENT>self.__logger.debug("<STR_LIT>" % method)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._auth_stage1()<EOL><DEDENT>
Try to authenticate using the first one of allowed authentication
        methods left.

        [client only]