trustpilot / python-trustpilot

Python HTTP client for Trustpilot.
MIT License
16 stars 4 forks source link

Headers passing as empty for async session #27

Closed chalama-ps closed 1 year ago

chalama-ps commented 1 year ago

I am receiving 403 error from trust pilot for last few days(it was working fine earlier) Error is [403 Forbidden]> <CIMultiDictProxy('Server': 'CloudFront', 'Date': 'Thu, 05 Oct 2023 11:04:25 GMT', 'Content-Type': 'text/html', 'Content-Length': '919', 'Connection': 'keep-alive', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 xxxxxxa.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'LHR61-P1', 'X-Amz-Cf-Id': 'xxxxxx') I am using trustpilot package and version is 9.0.0 self.session = async_client.TrustpilotAsyncSession( api_host="https://api.trustpilot.com", api_key=api_key, api_secret=api_secret, api_version="v1", username=username, password=password, ) print(self.session.headers) It returns empty {}

I tried with postman it works fine with just apikey `import requests

url = "https://api.trustpilot.com/v1/categories/xxxx/business-units?perPage=100&country=GB&page=1"

payload = {} headers = { 'apikey': 'xxxxxxxx' }

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)`

Am i doing something wrong here or it is the issue with trustpilot?

chalama-ps commented 1 year ago

I have just added self.session.headers = {"apikey": api_key} and it starts working. But not sure what has been changed in endpoint or module(i coudn't see any changes in module for last 3 months)

sneeu commented 1 year ago

Hi @chalama-ps, hopefully v10.0.1 will resolve your issue. Our API has been returning HTTP statuses of 403, in addition to 401 which weren’t being caught for authentication. You can see the change in #28.