marklagendijk / node-toogoodtogo-watcher

Node.js cli tool for monitoring your favorite TooGoodToGo businesses. Docker image available.
MIT License
363 stars 115 forks source link

Stopped working today, please help with the issue #100

Closed VeslavG closed 2 years ago

VeslavG commented 2 years ago

Stopped working today. Console output below, just changed the user email and user password. I've tried to clean session data in config file - it did not help.

=== Error during request: POST https://apptoogoodtogo.com/api/auth/v1/loginByEmail { "device_type": "UNKNOWN", "email": "_useremail", "password": "_userpass" }

HTTPError: Response code 403 (Forbidden) at Request. (C:\Users\Slava\AppData\Roaming\npm\node_modules\toogoodtogo-watcher\node_modules\got\dist\source\as-promise\index.js:117:42) at processTicksAndRejections (node:internal/process/task_queues:96:5)

VeslavG commented 2 years ago

Here is my api part of settings file. Could it be that we need a new user agent string, since TGTG has updated its app?

{ "api": { "credentials": { "email": "user_email", "password": "user_pass" }, "session": {}, "headers": { "User-Agent": "TooGoodToGo/20.6.1 (813) (iPhone/iPhone 7 (GSM); iOS 13.7; Scale/2.00)" }, "pollingIntervalInMs": 60000, "authenticationIntervalInMS": 3600000 },

Slothoncrack commented 2 years ago

Same issue here. Changing v1 to v2 in the Auth-API strings did not help either. Last time it worked for me was on Oct 2, the app was updated on Play Store already on Sep 27.

robpegurri commented 2 years ago

Same issue for me, getting 403 Forbidden

VeslavG commented 2 years ago

It worked fine today (2021-10-04), last time just about 2 hours ago. And about 2 hours this "403" started. (this is Windows box, no issues for the last month or so).

The app itself works fine on my Android with my Google profile - don't see any issues.

robpegurri commented 2 years ago

Okay, I solved it. I think they dropped support for older app. I set the user agent to:

User-Agent": "TooGoodToGo/21.9.0 (813) (iPhone/iPhone 7 (GSM); iOS 15.1; Scale/2.00)

and now everything looks working fine

Slothoncrack commented 2 years ago

Changing the user-agent seems to fix it :) Use: "User-Agent": "TooGoodToGo/21.9.3 (541) (iPhone/iPhone 7 (GSM); iOS 13.6; Scale/2.00)"

It seems to work for me!

VeslavG commented 2 years ago

cool, so my assumption about "user agent" is obsolete was correct! indeed it works now. the default config json requires update with new user agent - and after that this issue can be closed. thanks for your help!

Kwanaparis commented 2 years ago

HELP! PLEASE!

I am a newer in coding and Linux. I tried to follow the installation process given by the author. But after toogoodtogo-watcher config save and exit, and then I tried toogoodtogo-watcher watch, it reported errors as below. And I found config.json set as default again.

ERRORS:

Error during request: POST https://apptoogoodtogo.com/api/auth/v1/loginByEmail { "device_type": "UNKNOWN", "email": "Email of your TooGoodToGo account.", "password": "Password of your TooGoodToGo account." }

HTTPError: Response code 403 (Forbidden) at Request. (/usr/lib/node_modules/toogoodtogo-watcher/node_modules/got/dist/source/as-promise/index.js:117:42) at processTicksAndRejections (node:internal/process/task_queues:96:5)

VeslavG commented 2 years ago

https://github.com/marklagendijk/node-toogoodtogo-watcher/issues/100#issuecomment-933730535 change user agent sub-string in config file to below:

"User-Agent": "TooGoodToGo/21.9.3 (541) (iPhone/iPhone 7 (GSM); iOS 13.6; Scale/2.00)"

Kwanaparis commented 2 years ago

It still does not work. Once I tried toogoodtogo-watcher watch, it returns errors as mentioned above. And config.json is set as default. my changes were gone again. I have tried many times.

rayhvh commented 2 years ago

locally it seems to work. on heroku however im getting the same error as mentioned above. using "User-Agent": "TooGoodToGo/21.9.3 (541) (iPhone/iPhone 7 (GSM); iOS 13.6; Scale/2.00)"

When entering locally and getting an refresh token. Copying this token into the 'session' on my heroku config. it gives me the following error:


Error during request:
POST https://apptoogoodtogo.com/api/auth/v1/token/refresh
{
    "refresh_token": "e30.xxxxxxxxxxxxxxxxx"
}

HTTPError: Response code 403 (Forbidden)
    at Request.<anonymous> (/app/node_modules/got/dist/source/as-promise/index.js:117:42)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

Edit: I dont know how. but i went inside. using heroku run bash. then i did an remove: rm -r node_modules.. then i did an npm install. then i tried starting again. using node index.js watch. and now it seems to run. *(but only till i close the session)

MaxWinterstein commented 2 years ago

Okay, I solved it. I think they dropped support for older app. I set the user agent to:

User-Agent": "TooGoodToGo/21.9.0 (813) (iPhone/iPhone 7 (GSM); iOS 15.1; Scale/2.00)

and now everything looks working fine

Big thanks from my side, even I came from the python library.

It even seems you can provide anything as long as it differs from the original one.

broken: "TooGoodToGo/20.6.1 (813) (iPhone/iPhone 7 (GSM); iOS 13.7; Scale/2.00)"

working:

- "TooGoodToGo/20.6.1 (813) (iPhone/iPhone 7 (GSM); iOS 13.7; Scale/2.00)"
+ "TooGoodToGo/21.9.0 (813) (iPhone/iPhone 7 (GSM); iOS 15.1; Scale/2.00)"
- "TooGoodToGo/20.6.1 (813) (iPhone/iPhone 7 (GSM); iOS 13.7; Scale/2.00)"
+ "HP Deskjet 1125"

Seems like they start to blocklist user agents? 😲

Edit: copy/paste error

robpegurri commented 2 years ago

Seems like they start to blocklist user agents? 😲

I don’t think so. I suppose they are just dropping support for older app versions / iOS releases. But it’s just an opinion

MaxWinterstein commented 2 years ago

Seems like they start to blocklist user agents? 😲

I don’t think so. I suppose they are just dropping support for older app versions / iOS releases. But it’s just an opinion

Well, this is just another way of saying the blocklist something.

Looking at the version history of published iOS releases: https://apps.apple.com/us/app/too-good-to-go/id1060683933

🟢 21.6.0 is the most recent version that was published and works as user agent.
🔴 21.4.0 is the first one that fails, all others older than that (i tested) too.

But, if you play wildly with the user agent you see: 🟢 TooGoodToGo/99.9.9 (813) (iPhone/iPhone 7 (GSM); iOS 13.7; Scale/2.00) works fine
🟢 TooGoodToGo/10.11.0 (813) (iPhone/iPhone 7 (GSM); iOS 13.7; Scale/2.00) works fine 🟢 I should go back to work works fine

And also you see that:
🟢 JohnDoeFooBar/20.6.1 T-1000 Killing Machine works fine 🔴 TooGoodTogo/20.6.1 T-1000 Killing Machine won't work

As a conclusion of this I think they blocklist based on some logic like:

Or any other nasty way you can think of to provide this need.

jfadeuilhe commented 2 years ago

Merci ! 👍🏻

KaKi87 commented 2 years ago

[it] just pass[es] if its not found

In that case, I'm changing my UA string to just TooGoodToGo and I'll never have to worry about this issue again. 🙂

VeslavG commented 2 years ago

mine works fine today. I suggest to open a separate issue - this is denial due to badly formed request; not forbidden request.

lborruto commented 2 years ago

I tried to change the user agent to : TooGoodToGo/21.9.0 (813) (iPhone/iPhone 7 (GSM); iOS 15.1; Scale/2.00) TooGoodToGo/99.9.9 (813) (iPhone/iPhone 7 (GSM); iOS 13.7; Scale/2.00) TooGoodToGo/21.9.3 (541) (iPhone/iPhone 7 (GSM); iOS 13.6; Scale/2.00)

But I still have the same issue:

Error during request:
POST https://apptoogoodtogo.com/api/auth/v1/token/refresh
{
    "refresh_token": "XXXXXX"
}

HTTPError: Response code 401 (Unauthorized)
    at onResponse (/home/node/app/node_modules/got/dist/source/as-promise/index.js:142:28)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
Error during request:
POST https://apptoogoodtogo.com/api/auth/v1/token/refresh
{
    "refresh_token": "XXXXXX"
}

HTTPError: Response code 401 (Unauthorized)
    at onResponse (/home/node/app/node_modules/got/dist/source/as-promise/index.js:142:28)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
VeslavG commented 2 years ago

@iborruto Have you tried to clear everything in session? Just a suggestion, that you, need to clear user id and tokens, if you change the user agent. It would be strange to be connected to the same session, while having the new user agent. Again, this is just a suggestion which is very easy to check.

lborruto commented 2 years ago

@iborruto Have you tried to clear everything in session? Just a suggestion, that you, need to clear user id and tokens, if you change the user agent. It would be strange to be connected to the same session, while having the new user agent. Again, this is just a suggestion which is very easy to check.

I'm dumb. Thanks a lot it's finally working.

jfadeuilhe commented 2 years ago

no more alerts since the day before yesterday This may be related to commercial offers (https://tgtgnotif.rocks/ and https://tgtg-alerts.com/fr) What do you think ?

MaxWinterstein commented 2 years ago

no more alerts since the day before yesterday This may be related to commercial offers (https://tgtgnotif.rocks/ and https://tgtg-alerts.com/fr) What do you think ?

Definitely not. Your issue is based on this implementation, not their API in general. E.g. the python API wrapper https://github.com/ahivert/tgtg-python works pretty fine.

But, I am confident in saying that both commercial offers you mentioned are not welcomed by TGTG.
https://tgtg-notifier.com/en/ is a good example on that. Sadly my question to the owner why they closed it was never answered, but I guess scraping on a non-public API and selling a service based on that data is somehow a 'legal gray zone'.

Both mentioned websites lack some legal address or at least information on who owns them. https://who.is/whois/tgtg-alerts.com for example uses Whois privacy.

b00nswazzle commented 2 years ago

But does it work now or nah? At least I cannot seem to make it run with the changed user agents. I still geht the 403 error. I think it's because TGTG recently changed their login method. You don't need a password anymore, but get a single use login code sent to your email. Maybe that helps.

Myrodios commented 2 years ago

Yea same issue here. I get a 403 error and they did change their login method. Now u just type in your email address and get a one-time code for said device. At least thats what I had to do on my Android app just now.

VeslavG commented 2 years ago

I specifically went to android app to check. Yes, they have changed the authentication method to token-based. No more passwords. But watcher still works, because it pretends to be a separate client, with different (old, but still active) authentication.

When they will change the whole authentication (remove login/pass, and leave only email + token and couple of SSO (Google and Facebook) - then watcher should be (?) rewritten for token-based authentication (provide email, then catch token via email and provide it back).

jfadeuilhe commented 2 years ago

So it really doesn't work anymore : HTTPError: Response code 403 (Forbidden) Also : "device_type": "UNKNOWN",

Can we hope for a corrective version?

VeslavG commented 2 years ago

the app and agent are working properly now. raise your own issue, where describe all details and provide screenshots. it is very hard to say what is going with your agent on without details.

jfadeuilhe commented 2 years ago

Hello, I tried again this morning, it still doesn't work. :( I updated to version 3.6.6 I have the following message:


Error during request: POST https://apptoogoodtogo.com/api/item/v7/ { "favorites_only": true, "origin": { "latitude": 52.5170365, "longitude": 13.3888599 }, "radius": 200, "user_id": "xxxxxx" }

HTTPError: Response code 403 (Forbidden) at Request. (/usr/local/lib/node_modules/toogoodtogo-watcher/node_modules/got/dist/source/as-promise/index.js:117:42) at processTicksAndRejections (internal/process/task_queues.js:97:5)


The connection with Telegram is operational , /Stop & /Start displays: Removed chat Jacques Fadeuilhe (------) Added chat Jacques Fadeuilhe (------)

I did a config-reset and re-entered all the parameters, leaving :

"User-Agent": "TooGoodToGo/21.9.0 (813) (iPhone/iPhone 7 (GSM); iOS 15.1; Scale/2.00)"

Can you help me get back on the road?

Merci ! Jacques

jfadeuilhe commented 2 years ago

Ok, but I don't think that fixes my problems ...

jfadeuilhe commented 2 years ago

Switching to version 3.7.0 this morning: it works!

navimondo commented 2 years ago

After trying many combinations/tweaks, my toogoodwatcher service was able to login on the TGT platform with following code/settings combination:

api.js .post("auth/v2/loginByEmail", { json: { device_type: "ANDROID", email: credentials.email, password: credentials.password, }, }) "v1/loginByEmail" triggers an error "v2/loginByEmail" works If you encounter "HTTPError: Response code 403 (Forbidden)" ensure you are using the "v2"config.json "api": { "credentials": { "email": @.***", "password": "xxxx" }, "headers": { "User-Agent": "TooGoodToGo/21.9.0 (813) (iPhone/iPhone 7 (GSM); iOS 15.1; Scale/2.00)" },

-- cpt. Kris De Decker Business Developer www.scantainr.com [image: image.png] https://www.linkedin.com/in/dedeckerkris/

Le dim. 14 nov. 2021 à 06:31, FADEUILHE @.***> a écrit :

Switching to version 3.7.0 this morning: it works!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/marklagendijk/node-toogoodtogo-watcher/issues/100#issuecomment-968209983, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHGDRTULDQRMZZP7N2G63Y3UL5CTPANCNFSM5FI4XK2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.