mps-youtube / yewtube

yewtube, forked from mps-youtube , is a Terminal based YouTube player and downloader. No Youtube API key required.
GNU General Public License v3.0
8.07k stars 645 forks source link

"Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project" #1081

Closed ttofano closed 4 years ago

ttofano commented 4 years ago

I have been facing this error since yesterday (well, technicaly, earlier today, as it was around 4AM localtime when I found this issue for the first time). Does anybody know the reason?

The error (hostname omitted):

ttofano@_________ ~> mpsyt
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/pafy/util.py", line 34, in call_gdata
    data = g.opener.open(url).read().decode('utf-8')
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/mpsyt", line 11, in <module>
    load_entry_point('mps-youtube==0.2.8', 'console_scripts', 'mpsyt')()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2859, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.8/site-packages/mps_youtube/__init__.py", line 8, in <module>
    init.init()
  File "/usr/lib/python3.8/site-packages/mps_youtube/init.py", line 62, in init
    cache.load()
  File "/usr/lib/python3.8/site-packages/mps_youtube/cache.py", line 34, in load
    pafy.load_cache(cached['pafy'])
  File "/usr/lib/python3.8/site-packages/pafy/pafy.py", line 184, in load_cache
    set_categories(newcache.get('categories', {}))
  File "/usr/lib/python3.8/site-packages/pafy/pafy.py", line 171, in set_categories
    catinfo = call_gdata('videoCategories', query)
  File "/usr/lib/python3.8/site-packages/pafy/util.py", line 42, in call_gdata
    raise GdataError(errmsg)
pafy.util.GdataError: Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project 422897895433 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=422897895433 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

Here are my specs:

ttofano@_________ ~ [1]> mpsyt --version
mpsyt version      : 0.2.8
   notes           : released 17 February 2018
pafy version       : 0.5.5 (youtube-dl backend)
youtube-dl version : 2020.03.24
Python version     : 3.8.2 (default, Apr  8 2020, 14:31:25)
[GCC 9.3.0]
Processor          :
Machine type       : x86_64
Architecture       : 64bit, ELF
Platform           : Linux-5.6.8-arch1-1-x86_64-with-glibc2.2.5 (or Arch Linux, latest kernel)
sys.stdout.enc     : utf-8
default enc        : utf-8
Config dir         : /home/ttofano/.config/mps-youtube
env:TERM           : alacritty (though I tried other terminals and even getty, no success)
env:SHELL          : /usr/bin/fish (also tested in bash, same error)
env:LANG           : pt_BR.UTF-8

I tried opening the link provided in the error, but of course I have no privileges over the Google API project. So, any help would be appreciated! Thanks in advance.

salt42 commented 4 years ago

quick workaround: -> go to https://console.developers.google.com/ -> create account / login -> activate youtube api -> create api key -> replace the auth token in mpsyt by typing "set api_key YOUR_API_KEY" -> save & enjoy :)

ttofano commented 4 years ago

Hmm, I forgot to mention, but I do have an API key set already. Anyway, I deleted the .config/mps-youtube folder, reconfigured all back and now it is working again. Thanks for your time!

AaronAcerboni commented 4 years ago

I have the same issue which presents after I turn on my laptop again.

Deleting the python cache file in .config/mps-youtube specifically solves it.

ttofano commented 4 years ago

I have the same issue which presents after I turn on my laptop again.

Deleting the python cache file in .config/mps-youtube specifically solves it.

Should I reopen this issue? I can confirm that the cache seems to be the problem (which makes me happy already, as I had to reconfigure the thing everytime I wanted to use it lol)...

AaronAcerboni commented 4 years ago

@ttofano

I have a startup script deleting .config/mps-youtube every launch. For whatever reason it stores my api key anyway. It doesn't bother me anymore.

The stack trace isn't particularly helpful for whatever error is occuring so I would consider it unexpected behaviour and therefore a bug.

mavaa commented 4 years ago

Just a note, you don't have to remove the whole config folder, just the cachepy file. For some reason I have to do this every time I reboot, so as a workaround I've added this to my .rc file: `alias mpsyt="rm .config/mps-youtube/cachepy && mpsyt"`

I'm running v0.2.8, not sure if this is solved in develop.

AaronAcerboni commented 4 years ago

Oh yeah more specifically I am removing the cache_py* file