ahivert/tgtg-python

403 error

Closed this issue · 13 comments

Hi,
I am running tgtg in Home Assistant and am getting:

Source: custom_components/tgtg/sensor.py:108
Integration: Sensor (documentation, issues)
First occurred: December 13, 2021, 3:10:12 AM (1 occurrences)
Last logged: December 13, 2021, 3:10:12 AM

Error while setting up tgtg platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/tgtg/sensor.py", line 58, in setup_platform
    add_entities([TGTGSensor(each_item_id)])
  File "/config/custom_components/tgtg/sensor.py", line 76, in __init__
    self.update()
  File "/config/custom_components/tgtg/sensor.py", line 108, in update
    tgtg_answer = tgtg_client.get_item(item_id=self.item_id)
  File "/usr/local/lib/python3.9/site-packages/tgtg/__init__.py", line 238, in get_item
    self.login()
  File "/usr/local/lib/python3.9/site-packages/tgtg/__init__.py", line 119, in login
    self._refresh_token()
  File "/usr/local/lib/python3.9/site-packages/tgtg/__init__.py", line 109, in _refresh_token
    raise TgtgAPIError(response.status_code, response.content)
tgtg.exceptions.TgtgAPIError: (403, b'<html><head><title>apptoogoodtogo.com</title><style>#cmsg{animation: A 1.5s;}@keyframes A{0%{opacity:0;}99%{opacity:0;}100%{opacity:1;}}</style></head><body style="margin:0"><p id="cmsg">Please enable JS and disable any ad blocker</p><script>var dd={\'cid\':\'AHrlqAAAAAMA7epZgDR-8Y8BKhA3gReKAABmQr8Yv76uRg==\',\'hsh\':\'1D42C2CA6131C526E09F294FE96F94\',\'t\':\'fe\',\'r\':\'b\',\'s\':35560,\'host\':\'geo.captcha-delivery.com\'}</script><script src="https://ct.captcha-delivery.com/c.js"></script></body></html>\n')

I also reported this problem here: Chouffy/home_assistant_tgtg#13 but was forwarded to this repo.
Can someone help me get it to work again?

DL6ER commented

Are you already using the latest version of tgtg-python in your HomeAssistant sensor?

It is on 3.0.1 that should have 0.10.0 of tgtg-python.
The app is working on my mobile on the same network as the Home assistant instance yes.

Hello,

I'm having the same login issue today in my client app:

   raise TgtgLoginError(response.status_code, response.content)
tgtg.exceptions.TgtgLoginError: (403, b'<html><head><title>apptoogoodtogo.com</title><style>#cmsg{animation: A 1.5s;}@keyframes A{0%{opacity:0;}99%{opacity:0;}100%{opacity:1;}}</style></head><body style="margin:0"><p id="cmsg">Please enable JS and disable any ad blocker</p><script>var dd={\'cid\':\'AHrlqAAAAAMAWHV-2gp1eZIBKgEOCgLPq6A0YLT__t-v4Q==\',\'hsh\':\'1D42C2CA6131C526E09F294FE96F94\',\'t\':\'fe\',\'r\':\'b\',\'s\':35694,\'host\':\'geo.captcha-delivery.com\'}</script><script src="https://ct.captcha-delivery.com/c.js"></script></body></html>\n')

I had the error running 0.10.1 and it's still broken after upgrading to 0.11.0

Am I missing something ?
Thanks

@seymourd are you connected to a VPN? I had the same login issue (using version 0.11.0) which was fixed by disconnecting from my VPN.

Nope, I am running a script on a Debian VM.
Weirdly, I tried the script directly from my computer and it logs just fine, whereas it fails systematically on my VM.
Any clue ?

The VM and your computer use the same public IP address? Tgtg ban your IP if you abuse a little bit.

Yes, same public adress.
The vm is hosted on my modem.

Edit :
Works this morning. Don't know why though.

Hello again,

I'm still having the issue every now and then, from various clients under Unix:

  • A client I developed, running on Debian
  • The same one running on Ubuntu
  • Chouffy's integration in HomeAssistant

However, my own client is running fine on windows.

I've been trying to change the requests lib with other ones (requestium, requests_http) with the same result.
@maartenhendrix, how is it going for you now ?

Anyone, any clue on this annoying issue ?

Thanks

Hello again,

I'm still having the issue every now and then, from various clients under Unix:

  • A client I developed, running on Debian
  • The same one running on Ubuntu
  • Chouffy's integration in HomeAssistant

However, my own client is running fine on windows.

I've been trying to change the requests lib with other ones (requestium, requests_http) with the same result. @maartenhendrix, how is it going for you now ?

Anyone, any clue on this annoying issue ?

Thanks

I stopped using it for a while and tried again a week ago or so. Now it is working. Maybe tgtg uses some kind of DoS protection or something. On the other hand the app was working fine from the same network.

Hello again,
I'm still having the issue every now and then, from various clients under Unix:

  • A client I developed, running on Debian
  • The same one running on Ubuntu
  • Chouffy's integration in HomeAssistant

However, my own client is running fine on windows.
I've been trying to change the requests lib with other ones (requestium, requests_http) with the same result. @maartenhendrix, how is it going for you now ?
Anyone, any clue on this annoying issue ?
Thanks

I stopped using it for a while and tried again a week ago or so. Now it is working. Maybe tgtg uses some kind of DoS protection or something. On the other hand the app was working fine from the same network.

They seem to use https://datadome.co/ which gives a cookie per device it seems 🤔

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Still relevant, not passing datadome cookie breaks app.