ahivert / tgtg-python

Unofficial client for TooGoodToGo API
GNU General Public License v3.0
374 stars 71 forks source link

403 error #131

Closed maartenhendrix closed 2 years ago

maartenhendrix commented 2 years ago

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: https://github.com/Chouffy/home_assistant_tgtg/issues/13 but was forwarded to this repo. Can someone help me get it to work again?

DL6ER commented 2 years ago

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

ahivert commented 2 years ago

Is the app working using the same IP (logout and login)? Are you sure you have the last version of tgtg-python ?

On Tue, Dec 14, 2021, 20:50 Maarten @.***> wrote:

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'apptoogoodtogo.com

Please enable JS and disable any ad blocker

\n')

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

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ahivert/tgtg-python/issues/131, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACWV4UQBR5HMH3WMQ5FMQ6DUQ6NXHANCNFSM5KBYWAVQ .

maartenhendrix commented 2 years ago

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.

seymourd commented 2 years ago

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

CameronLP commented 2 years ago

@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.

seymourd commented 2 years ago

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 ?

ahivert commented 2 years ago

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

On Sat, Jan 22, 2022, 16:21 seymourd @.***> wrote:

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 ?

— Reply to this email directly, view it on GitHub https://github.com/ahivert/tgtg-python/issues/131#issuecomment-1019290793, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACWV4URSIE5366DYDOOJCQTUXLDO5ANCNFSM5KBYWAVQ . You are receiving this because you commented.Message ID: @.***>

seymourd commented 2 years ago

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.

seymourd commented 2 years ago

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

maartenhendrix commented 2 years ago

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.

manniL commented 2 years ago

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[bot] commented 2 years ago

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.

EsEnZeT commented 2 years ago

Still relevant, not passing datadome cookie breaks app.