code: def generate_string_to_sign(date, region, canonical_request):
      
      formatted_date_time = date.strftime("%Y%m%dT%H%M%SZ")
  
      canonical_request_hasher = hashlib.sha256()
      canonical_request_hasher.update(canonical_request.encode('utf-8'))
      canonical_request_sha256 = canonical_request_hasher.hexdigest()
      scope = generate_scope_string(date, region)
  
      return '\n'.join([_SIGN_V4_ALGORITHM,
                        formatted_date_time,
                        scope,
                        canonical_request_sha256])
docs: Generate string to sign.
  
      :param date: Date is input from :meth:`datetime.datetime`
      :param region: Region should be set to bucket region.
      :param canonical_request: Canonical request generated previously.