emailage / Emailage_Python

Official Emailage API client for Python 2.7 and 3+
Other
6 stars 5 forks source link

Possibility to send queries via POST instead of GET #23

Closed bluefish6 closed 4 years ago

bluefish6 commented 4 years ago

Based on Zendesk Support Request #3123 information, very long queries that contain long values (which is common for non-ascii addresses, where Тюменская область would be encoded as %D0%A2%D1%8E%D0%BC%D0%B5%D0%BD%D1%81%D0%BA%D0%B0%D1%8F%20%D0%BE%D0%B1%D0%BB%D0%B0%D1%81%D1%82%D1%8C) can sometimes hit an empirical limit of 2048 chars in query string which seems to be present on api.emailage.com environment.

Support team gave us the information in the mentioned support thread:

we also support a URL Encoded form body in a POST Request if the GET method is causing issues.

Could you please change the method used to send queries from GET to POST or enable enforcing POST requests via some EmailageClient.__init__() argument?

bluefish6 commented 4 years ago

The parameters sent in GET query string instead of POST body are also an issue for cases like:

import emailage
client=emailage.client.EmailageClient(secret='REDACTED_SECRET', token='REDACTED_TOKEN', sandbox=True)

resp = client.query_email_and_ip_address(
    "foobarbazbaz@icloud.com",
    "211.11.222.11",
    billaddress="UAE 🇦🇪, DUBAI, OUD METHA",
)
print(resp) 

where even with correct secret and token, the response is stating that the credentials are incorrect:

{'query': {'email': 'foobarbazbaz@icloud.com+211.11.222.11', 'queryType': 'EmailIPRisk', 'count': 1, 'created': '2020-01-02T18:05:43Z', 'lang': 'en-US', 'responseCount': 0, 'billaddress': 'UAE%20%F0%9F%87%A6%F0%9F%87%AA%2C%20DUBAI%2C%20OUD%20METHA', 'results': []}, 'responseStatus': {'status': 'failed', 'errorCode': '3001', 'description': 'Authentication Error: The signature does not match or the user/consumer key was not found.'}}

Note that the billaddress contains the AE flag: 🇦🇪.

We got a confirmation from Zendesk support ticket 3131 that the issue is present in the API itself and that it occurs only when the flag is sent in GET querystring, but that the API undestands the credentials correctly if the same parameters are sent in POST body.

So there are already 2 reasons to switch from GET to POST.

gtraines-emailage commented 4 years ago

Hi @bluefish6 , we are working on those suggestions now. Thanks!

gtraines-emailage commented 4 years ago

Done and pushed to PyPI https://pypi.org/project/emailage-official/1.2.0/