@staticmethod<EOL><INDENT>def generate_telesign_headers(customer_id,<EOL>api_key,<EOL>method_name,<EOL>resource,<EOL>url_encoded_fields,<EOL>date_rfc2616=None,<EOL>nonce=None,<EOL>user_agent=None,<EOL>content_type=None):<DEDENT>
if date_rfc2616 is None:<EOL><INDENT>date_rfc2616 = formatdate(usegmt=True)<EOL><DEDENT>if nonce is None:<EOL><INDENT>nonce = str(uuid.uuid4())<EOL><DEDENT>if not content_type:<EOL><INDENT>content_type = "<STR_LIT>" if method_name in ("<STR_LIT:POST>", "<STR_LIT>") else "<STR_LIT>"<EOL><DEDENT>auth_method = "<STR_LIT>"<EOL>string_to_sign_builder = ["<STR_LIT>".format(method=method_name)]<EOL>string_to_sign_builder.append("<STR_LIT>".format(content_type=content_type))<EOL>string_to_sign_builder.append("<STR_LIT>".format(date=date_rfc2616))<EOL>string_to_sign_builder.append("<STR_LIT>".format(auth_method=auth_method))<EOL>string_to_sign_builder.append("<STR_LIT>".format(nonce=nonce))<EOL>if content_type and url_encoded_fields:<EOL><INDENT>string_to_sign_builder.append("<STR_LIT>".format(fields=url_encoded_fields))<EOL><DEDENT>string_to_sign_builder.append("<STR_LIT>".format(resource=resource))<EOL>string_to_sign = "<STR_LIT>".join(string_to_sign_builder)<EOL>signer = hmac.new(b64decode(api_key), string_to_sign.encode("<STR_LIT:utf-8>"), sha256)<EOL>signature = b64encode(signer.digest()).decode("<STR_LIT:utf-8>")<EOL>authorization = "<STR_LIT>".format(<EOL>customer_id=customer_id,<EOL>signature=signature)<EOL>headers = {<EOL>"<STR_LIT>": authorization,<EOL>"<STR_LIT>": date_rfc2616,<EOL>"<STR_LIT:Content-Type>": content_type,<EOL>"<STR_LIT>": auth_method,<EOL>"<STR_LIT>": nonce<EOL>}<EOL>if user_agent:<EOL><INDENT>headers['<STR_LIT>'] = user_agent<EOL><DEDENT>return headers<EOL>
Generates the TeleSign REST API headers used to authenticate requests.

Creates the canonicalized string_to_sign and generates the HMAC signature. This is used to authenticate requests
against the TeleSign REST API.

See https://developer.telesign.com/docs/authentication for detailed API documentation.

:param customer_id: Your account customer_id.
:param api_key: Your account api_key.
:param method_name: The HTTP method name of the request as a upper case string, should be one of 'POST', 'GET',
    'PUT' or 'DELETE'.
:param resource: The partial resource URI to perform the request against, as a string.
:param url_encoded_fields: HTTP body parameters to perform the HTTP request with, must be a urlencoded string.
:param date_rfc2616: The date and time of the request formatted in rfc 2616, as a string.
:param nonce: A unique cryptographic nonce for the request, as a string.
:param user_agent: (optional) User Agent associated with the request, as a string.
:param content_type: (optional) ContentType of the request, as a string.
:return: The TeleSign authentication headers.