ThioJoe / YT-Spammer-Purge

Allows you easily scan for and delete scam comments using several methods.
GNU General Public License v3.0
4.53k stars 389 forks source link

[Bug]: Token.pickle not refreshed if credentials changed #434

Open harrim4n opened 2 years ago

harrim4n commented 2 years ago

Duplicate Issues

What happened?

I used an old project to create the new credentials. I saved the oauth info to the client_secrets.json file and got an API quota exceeded error, because (as I then noticed) the project has an API limit of 0 requests per day. So I created a new project, downloaded the new credentials, but the error still appeared. Only after I removed the token.pickle file and ran through the OAuth flow for the new credentials did the tool work. As users might try to create multiple projects and switch between json configs, they would then still get the errors from the old account.

Release version

No response

Steps to reproduce

  1. Exceed API limit for one project
  2. Switch client_secrets.json to other project
  3. Try to run tool

What platform are you seeing this problem on?

Linux (can also be ChromeOS)

Relevant log output

No response

Screenshots

No response

KendallDoesCoding commented 2 years ago

Duplicate Issues

  • [x] There are no existing posts relating to my problem
  • [ ] There are existing posts relating to my problem, but the solution given, doesn't work for me.

What happened?

I used an old project to create the new credentials. I saved the oauth info to the client_secrets.json file and got an API quota exceeded error, because (as I then noticed) the project has an API limit of 0 requests per day. So I created a new project, downloaded the new credentials, but the error still appeared. Only after I removed the token.pickle file and ran through the OAuth flow for the new credentials did the tool work. As users might try to create multiple projects and switch between json configs, they would then still get the errors from the old account.

Release version

No response

Steps to reproduce

  1. Exceed API limit for one project
  2. Switch client_secrets.json to other project
  3. Try to run tool

What platform are you seeing this problem on?

Linux (can also be ChromeOS)

Relevant log output

No response

Screenshots

No response

Can you share a screenshot of the error?

ThioJoe commented 2 years ago

Yea this is something I've run into myself, so I thought I added a message mentioning a particular error could be because of a mis-matched client_secrets and token.pickle file

harrim4n commented 2 years ago

This is the current error message:

~ python YTSpammerPurge.py

Loading YT Spammer Purge @ 2.14.0...
Checking for updates to program and spam lists...

Getting info about latest updates...

Loading other assets..

===================== YOUTUBE SPAMMER PURGE v2.14.0 =====================
=========== https://github.com/ThioJoe/YT-Spammer-Purge ===========
================= Author: ThioJoe - YouTube.com/ThioJoe ================

Purpose: Lets you scan for spam comments and mass-delete them all at once

NOTE: It's probably better to scan individual videos, because you can scan all those comments,
      but scanning your entire channel must be limited and might miss older spam comments.
You will be shown the comments to confirm before they are deleted.
Traceback (most recent call last):
  File "/home/harrim4n/YT-Spammer-Purge/YTSpammerPurge.py", line 1478, in <module>
    main()
  File "/home/harrim4n/YT-Spammer-Purge/YTSpammerPurge.py", line 290, in main
    userInfo = auth.get_current_user(config)
  File "/home/harrim4n/YT-Spammer-Purge/Scripts/auth.py", line 113, in get_current_user
    results = fetch_user()
  File "/home/harrim4n/YT-Spammer-Purge/Scripts/auth.py", line 111, in fetch_user
    ).execute()
  File "/usr/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 131, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/googleapiclient/http.py", line 937, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://youtube.googleapis.com/youtube/v3/channels?part=snippet&mine=true&fields=items%2Fid%2Citems%2Fsnippet%2Ftitle&alt=json returned "The request cannot be completed because you have exce
eded your <a href="/youtube/v3/getting-started#quota">quota</a>.". Details: "[{'message': 'The request cannot be completed because you have exceeded your <a href="/youtube/v3/getting-started#quota">quota</a>.', 'domain': 'youtube.quota', 'reason': 'quotaE
xceeded'}]">
------------------------------------------------
Error Message: <HttpError 403 when requesting https://youtube.googleapis.com/youtube/v3/channels?part=snippet&mine=true&fields=items%2Fid%2Citems%2Fsnippet%2Ftitle&alt=json returned "The request cannot be completed because you have exceeded your <a href="
/youtube/v3/getting-started#quota">quota</a>.". Details: "[{'message': 'The request cannot be completed because you have exceeded your <a href="/youtube/v3/getting-started#quota">quota</a>.', 'domain': 'youtube.quota', 'reason': 'quotaExceeded'}]">
Status Code: 403
    Reason: quotaExceeded

Error: You have exceeded the YouTube API quota. To do more scanning you must wait until the quota resets.
 > There is a daily limit of 10,000 units/day, which works out to around reporting 10,000 comments/day.
 > You can check your quota by searching 'quota' in the google cloud console.
Solutions: Either wait until tomorrow, or create additional projects in the cloud console.
  > Read more about the quota limits for this app here: TJoe.io/api-limit-info

An 'HttpError' was raised. This is sometimes caused by a remote server error. See the error info above.
If this keeps happening, consider posting a bug report on the GitHub issues page, and include the above error info.
Short Link: TJoe.io/bug-report

Press Enter to Exit...
ThioJoe commented 2 years ago

Ah I see, I'll have to see if I can come up with something

KendallDoesCoding commented 2 years ago

This is the current error message:

~ python YTSpammerPurge.py

Loading YT Spammer Purge @ 2.14.0...
Checking for updates to program and spam lists...

Getting info about latest updates...

Loading other assets..

===================== YOUTUBE SPAMMER PURGE v2.14.0 =====================
=========== https://github.com/ThioJoe/YT-Spammer-Purge ===========
================= Author: ThioJoe - YouTube.com/ThioJoe ================

Purpose: Lets you scan for spam comments and mass-delete them all at once

NOTE: It's probably better to scan individual videos, because you can scan all those comments,
      but scanning your entire channel must be limited and might miss older spam comments.
You will be shown the comments to confirm before they are deleted.
Traceback (most recent call last):
  File "/home/harrim4n/YT-Spammer-Purge/YTSpammerPurge.py", line 1478, in <module>
    main()
  File "/home/harrim4n/YT-Spammer-Purge/YTSpammerPurge.py", line 290, in main
    userInfo = auth.get_current_user(config)
  File "/home/harrim4n/YT-Spammer-Purge/Scripts/auth.py", line 113, in get_current_user
    results = fetch_user()
  File "/home/harrim4n/YT-Spammer-Purge/Scripts/auth.py", line 111, in fetch_user
    ).execute()
  File "/usr/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 131, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/googleapiclient/http.py", line 937, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://youtube.googleapis.com/youtube/v3/channels?part=snippet&mine=true&fields=items%2Fid%2Citems%2Fsnippet%2Ftitle&alt=json returned "The request cannot be completed because you have exce
eded your <a href="/youtube/v3/getting-started#quota">quota</a>.". Details: "[{'message': 'The request cannot be completed because you have exceeded your <a href="/youtube/v3/getting-started#quota">quota</a>.', 'domain': 'youtube.quota', 'reason': 'quotaE
xceeded'}]">
------------------------------------------------
Error Message: <HttpError 403 when requesting https://youtube.googleapis.com/youtube/v3/channels?part=snippet&mine=true&fields=items%2Fid%2Citems%2Fsnippet%2Ftitle&alt=json returned "The request cannot be completed because you have exceeded your <a href="
/youtube/v3/getting-started#quota">quota</a>.". Details: "[{'message': 'The request cannot be completed because you have exceeded your <a href="/youtube/v3/getting-started#quota">quota</a>.', 'domain': 'youtube.quota', 'reason': 'quotaExceeded'}]">
Status Code: 403
    Reason: quotaExceeded

Error: You have exceeded the YouTube API quota. To do more scanning you must wait until the quota resets.
 > There is a daily limit of 10,000 units/day, which works out to around reporting 10,000 comments/day.
 > You can check your quota by searching 'quota' in the google cloud console.
Solutions: Either wait until tomorrow, or create additional projects in the cloud console.
  > Read more about the quota limits for this app here: TJoe.io/api-limit-info

An 'HttpError' was raised. This is sometimes caused by a remote server error. See the error info above.
If this keeps happening, consider posting a bug report on the GitHub issues page, and include the above error info.
Short Link: TJoe.io/bug-report

Press Enter to Exit...

Thanks!

TechStudent10 commented 1 year ago

Nearly a year since last response