MarcelRobitaille / bbyen

Bring Back YouTube Email Notifications! YouTube upload email notification replacement
MIT License
10 stars 0 forks source link

invalid_grant #7

Closed ghost closed 2 years ago

ghost commented 3 years ago

Been receiving 'invalid_grant' return after the script was working perfectly for a few days

MarcelRobitaille commented 3 years ago

Oh man I remember getting that error in a different project years ago and fighting with it for like a week. It's a google error that can mean any number of things and isn't documented.

I remember this article helped me last time: https://blog.timekit.io/google-oauth-invalid-grant-nightmare-and-how-to-fix-it-9f4efaf1da35?gi=d0eca552387f. Would you mind reading through there and see if anything matches your situation? If not, I can try to help you track it down. It's more a problem on Google's end than a bug in my software. I'm sorry you're getting this, but there isn't much I can do.

MarcelRobitaille commented 3 years ago

Any luck?

ghost commented 3 years ago

Tried all that I could from that guide, was easier to make a new project with google developer console. I have been just running it off of my pc and starting it up in the morning, going to get a new Pi soon and run it off of that incase it has something to do with multiple signons

MarcelRobitaille commented 3 years ago

Sounds like you fixed this. I am closing it for now. Feel free to reopen.

NightMean commented 2 years ago

Reopening as I experienced the same issue on my 2nd Google Project. Creating new project does solve the issue but only temporarily. bbyen was working perfectly fine for couple of days, after that out of nowhere invalid_grant was shown. No changes were done to the config file.

Edit: Could not re-open as I'm not the creator of the issue. @MarcelRobitaille could you re-open?

MarcelRobitaille commented 2 years ago

If it's showing up only after a couple of days, it could be that you're refreshing too quickly and hitting your quota. What is your refresh time?

I know this is frustrating, and I've been there, but this is really more a problem with Google's API. The best I can do is link you suggestions to try.

You can try:

NightMean commented 2 years ago

Unfortunately I have ~600 subscriptions and ~300 in the whitelist config. (I know, it's a lot) However most of the channels don't upload anything these days or only once per month. The total amount of videos I get per day is around 30-40 if not bit less.

I guess you're right about the quota. I thought that 2 hours might be enough but I might as well change it to 1 day or more. No need to check it that often. Does bbyen uses the quota during video scan as well? I assume that the quota is being used only during the subscription check as the videos are parsed from RSS.

"timers": {
                "subscriptions": "2 hours",
                "videos": "10 minutes"

Edit: I just removed the .google-auth-token.json file and re-authorized again. The invalid_grant error is gone and there is no need to delete existing project and create a new one! :) Not an ideal workaround but still much better than deleting whole Google project. I guess you're right about the Google API. Will monitor this in the next coming days.

MarcelRobitaille commented 2 years ago

The google API is used to check for new subscriptions and to get extra information about new videos. You are correct that RSS is used to check if a channel has new videos. I have my subscriptions update to 3 days for that reason. Videos should be within your quota unless you have hundreds of new videos every day. Hundreds of channels is fine because those are checked with RSS.

Checking for subscriptions takes 1 quota unit per page of 50 results. If you have 600 subscriptions, that makes 12 units every 2 hours, 144 per day. I would think that would be within the limit. I just checked my dashboard and I have some days in the 120s. Maybe it's because of the videos too? You can also see your quota exceeded error count in the dashboard if you go to the YouTube data api in your Google Cloud console, click manage, then click quotas.

NightMean commented 2 years ago

Thanks for the heads up.

The error count did go up once the invalid_grant error was shown. I checked previous days when it worked and I noticed that I have ~1000 - 1300 queries per day. That is still within the 10k limit per day. Since yesterday as I adjusted the config to check subscriptions every 24 hours the queries dropped to 680. I can't check graphs from the past as that was in the previous projects which are now deleted. I only have data for ~6 days in total. Will keep an eye on this.

MarcelRobitaille commented 2 years ago

It sounds like you solved your issue for now @NightMean. I'm going to close this. Please feel free to open again.