def validate(self, uri, params, signature):
if params is None:<EOL><INDENT>params = {}<EOL><DEDENT>parsed_uri = urlparse(uri)<EOL>if parsed_uri.scheme == "<STR_LIT>" and parsed_uri.port:<EOL><INDENT>uri = remove_port(parsed_uri)<EOL><DEDENT>valid_signature = False  <EOL>valid_body_hash = True  <EOL>query = parse_qs(parsed_uri.query)<EOL>if "<STR_LIT>" in query and isinstance(params, string_types):<EOL><INDENT>valid_body_hash = compare(self.compute_hash(params), query["<STR_LIT>"][<NUM_LIT:0>])<EOL>valid_signature = compare(self.compute_signature(uri, {}), signature)<EOL><DEDENT>else:<EOL><INDENT>valid_signature = compare(self.compute_signature(uri, params), signature)<EOL><DEDENT>return valid_signature and valid_body_hash<EOL>
Validate a request from Twilio

        :param uri: full URI that Twilio requested on your server
        :param params: dictionary of POST variables or string of POST body for JSON requests
        :param signature: expected signature in HTTP X-Twilio-Signature header

        :returns: True if the request passes validation, False if not