Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default api key disabled #1063

Closed
pirate486743186 opened this issue Feb 23, 2020 · 62 comments
Closed

default api key disabled #1063

pirate486743186 opened this issue Feb 23, 2020 · 62 comments

Comments

@pirate486743186
Copy link
Contributor

It seams that google has disabled the default api key.

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.

@celtichawk
Copy link

Confirming this too, I just did a fresh install and am running into the same issue.

@celtichawk
Copy link

Also adding that after setting my own API V3 key, it still gives me an access not configured error as well.

@thezeroalpha
Copy link

thezeroalpha commented Feb 23, 2020

Same, it seems like it could be related to caching, as after removing ~/.config/mps-youtube/cache_py*, it works for some time (haven't yet found what causes the issue to resurface).

Edit for clearer explanation of steps: when trying to start mpsyt, I get error 403. Then I remove the cache file, open mpsyt, and set api_key to my own API key. This works for some time, but later for some reason, it gives me the error again. So, I remove the cache file, and open mpsyt. At this point, api_key is set correctly, but I still get the error until I remove the cache file.

@temavasilev
Copy link

Same, it seems like it could be related to caching, as after removing ~/.config/mps-youtube/cache_py*, it works for some time (haven't yet found what causes the issue to resurface).

Edit for clearer explanation of steps: when trying to start mpsyt, I get error 403. Then I remove the cache file, open mpsyt, and set api_key to my own API key. This works for some time, but later for some reason, it gives me the error again. So, I remove the cache file, and open mpsyt. At this point, api_key is set correctly, but I still get the error until I remove the cache file.

Can confirm that the following steps solve the issue for me.

@sokolgeo
Copy link

Same issue, deleting cache_py folder leads to same error after running mpsyt

@paulfertser
Copy link
Contributor

This bug is related to pafy issue: mps-youtube/pafy#255

@whitemind
Copy link

Hello,

Same thing here,

I've deleted the cache_py but still has the fetching error below:

Error fetching data. Possible network issue.
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.

mpsyt --version
mpsyt version : 0.2.8
notes : released 17 February 2018
pafy version : 0.5.4 (youtube-dl backend)
youtube-dl version : 2020.02.16
Python version : 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0]
Processor :
Machine type : x86_64
Architecture : 64bit, ELF
Platform : Linux-4.19.0-8-amd64-x86_64-with-debian-10.3
sys.stdout.enc : UTF-8
default enc : utf-8
Config dir : /home/asterix/.config/mps-youtube
env:TERM : xterm
env:SHELL : /bin/bash
env:LANG : en_US.UTF-8
env:LANGUAGE : en_US:en

Regards

@mateuszr
Copy link

Actually this doesn't look like pafy related bug. It's rather some change on the google side. You can make it work by creating your own app and generate new API key, see: mps-youtube/pafy#255 (comment). What's important is to make sure that the new API is used and not the hardcoded "AIzaSyCIM4EzNqi1in22f4Z3Ru3iYvLaY8tc3bo" key (see #1061)

@orbea
Copy link

orbea commented Feb 25, 2020

Can a new hardcoded key be generated for pafy? Its not possible to make your own key without a google account.

@nishanmudalige
Copy link

nishanmudalige commented Feb 25, 2020

I am on a Mac running macOS 10.15 and I solved this issue by doing the following:

  • deleted the contents of the __ pycache __ folder (note: I only deleted the files , I did not delete the folder. Also note that there are no spaces in the folder name. Markdown would make the text bold if I did not include spaces.)
  • On google developer pages:
  • using search, replaced every instance of default key with new key generated (in mpsyt config file and pafy and all g.py files I could find)

This solved the issue for me

@oskarvid
Copy link

@nishanmudalige, can confirm, this worked for me too. I think the key is to make a new project with a new api key because it wasn't until I did that that it actually worked. I only needed to edit mps_youtube/config.py and build/lib/mps_youtube/config.py to make it work. I tried to change it with set api_key at first but it wouldn't let me for some reason.

@whitemind
Copy link

whitemind commented Feb 25, 2020

Hello,

It's working after some steps

Here are the steps I took:

  1. Create an API project like nishanmudalige said by following the steps he mentioned.
  2. Delete the mps-youtube cache file [cache_py_3.7xxx] related to your version of python, so make sure it is the correct file located on the folder /.config/mps-youtube/ for me it was cache_py_3.7.4
  3. Go to the folder /usr/local/lib/python3.7/dist-packages/mps_youtube and open the fle config.py, make sure to do a backup of the file before making any modifications, i think if you delete the file it will automatically create a new one after executing mpsyt but you lose any configuration you might have before. Near the end of the file, there is a configuration where it has the youtube api_key, you should substitute that value with your new one previously created on point 1.
  4. Then go to the folder /.config/mps-youtube and open the file config.py and update the api_key with your new api_key.

That should work

Hope it helps
Best regards

@elig0n
Copy link

elig0n commented Feb 25, 2020

After reading all the above I managed to solve it with steps similar to what @whitemind and @nishanthkarthik suggested but I had to start with a fresh ~/.config/mps-youtube directory because modifying the binary config file for the new api_key did not prove to work for me. The steps I followed were:

  1. Create a new google api project. I called it mps-youtube but you can call it whatever. Enable Youtube v3 API and get the API Key.
  2. Change the default key from python version directory's /dist-packages/pafy/g.py and /dist-packages/mps_youtube/config.py
  3. Remove __pycache__/ directory content from both above mentioned pafy/ and mps_youtube/ module dirs.
  4. Remove ~/.config/mps-youtube directory (you may want to backup your histories and configurations but at least for configurations I suggest you copy/reinput them manually one by one)

@pirate486743186
Copy link
Contributor Author

The REAL solution here, would be, for the person that controls the default key, to reactivate it....

kof kof
@hrnr @kraetzin @ids1024 @ritiek @vn-ki

That changing the api key is actually bugged, is a different problem.

@ritiek
Copy link
Member

ritiek commented Feb 26, 2020

That API key is about 5 years old and was added in 032cca9 by @ids1024. I don't expect @ids1024 to still remember the account information from which the key was created, after such a long time. I also don't expect it would be as easy to simply reactivate the key as API keys don't usually expire. I believe this error is probably a side effect of something else YouTube did lately.

We could also generate a new YouTube Data API key but it would easily be hitting rate limits as API keys that were generated in those old times could be used for 50 million units/day, but now has been dropped to only 1 million units/day.

@cirrusUK
Copy link

cirrusUK commented Feb 26, 2020

FWIW a similar project https://github.com/trizen/youtube-viewer recently also had their API disabled & urged all users to go create their own API key for the same reasons @ritiek suggests. IE: 'new YouTube Data API key would easily be hitting rate limits ' sadly it appears that project is now doomed because of this. the developer recently posted this trizen/youtube-viewer#308 however in recent days he has stuck a fork in it trizen/youtube-viewer#308 (comment)
maybe mpsyt too could use a similar API as straw-viewer, I really hope we can find a way forward for mpsyt

@thezeroalpha
Copy link

Related to using our own API key -- is there any way to set the key from the environment, instead of setting it directly in the json file? I like to keep my configuration on github under version control, and I'd rather not push API keys to github.

@whitemind
Copy link

Hi

Yes you can,

mpsyt set api_key your_key

Regards

@TalhaAkber
Copy link

TalhaAkber commented Feb 26, 2020

  1. Go to https://console.cloud.google.com, create a project, then enable Youtube Data Api V3 and create credential and get the API_KEY for public use.
  2. Then remove the cache rm ~/.config/mps-youtube/cache_py*
  3. Set the new api key mpsyt set api_key YOUR_KEY_HERE
  4. Quit mpsyt (if there are any opened mpsyt instances"
  5. Open it again and use it normally (it worked for me after following these steps)

@thezeroalpha
Copy link

Yes, but this writes the key into the JSON config file, AFAIK. My question is, is it possible to have the API key set to eg. the environment variable $YT_API_KEY, and have mpsyt read this variable?

@ghost
Copy link

ghost commented Feb 27, 2020

Is there any way for those with no google/youtube account to use mps-yt now?

@paulfertser
Copy link
Contributor

paulfertser commented Feb 27, 2020 via email

@AyoungDukie
Copy link

AyoungDukie commented Feb 27, 2020

So I looked at an alternative player to handle livestreams (as I could not get those working even prior to this API issue, haha), and came across an application using an OSS tool called invidous [ Website, Github ] (license is stated as AGPLv3); seems they have their own access API setup as well, so may be worth looking into, but also seems like a lot of retooling to point at a different site than YT proper....

@sebma
Copy link

sebma commented Feb 28, 2020

I don't think average users are going to be able to do create a new API key.
Can you guys please do it inside mps-youtube/pafy module instead ?

@AyoungDukie
Copy link

AyoungDukie commented Feb 28, 2020

Just as a workaround for those starting to re-encounter this 403 error with their own API keys (which I started to have when I came across this open issue), some people have pointed out that the Google API can do a poor job of propogating changes to fix issues stack overflow post, so I went and fully deleted my api project, set up a new one from scratch, and created new API credentials. Once done, MPSYT was functional again with the new key.

@Jeronimo17
Copy link

With own API, if I disconnect the network or delete the cache that is said in other posts, it goes well but works like 1 day

@lakelord
Copy link

lakelord commented Mar 2, 2020

Ok... I did all modifications and exchanged the API key for a new key. bout now....the player software does not seem to play musics.....it crashes.... I can search and get a list, but not play anything.
Any guesses ?

@sebma
Copy link

sebma commented Mar 6, 2020

@T0MuX Thanks for Invidious :) and their source code is at github.

Also hoping that SMTube is going to switch from Tonvid to Invidious.

@TalhaAkber
Copy link

I am not sure we can quite call it "solution" when each user needs creating his individual Google API key: 1. Its relatively high effort for non-technically minded 2. It decreases your privacy level. With one API key Google was tracking multitude of IP addresses all using the same key, but with each user creating his own key - Google will track you even better due to your key being unique ID. Before I could put mpsyt beyond Tor proxy and call it a day. Now individual API key would probably mean more work to reach the same level of privacy as before (creating fake google account just to create the individual API key which is not linked to my personality known by google). That is probably doable, still step in worse direction IMHO.

On March 3, 2020 1:03:04 AM GMT+01:00, Alex Zinchenko @.***> wrote: @TalhaAkber Thanks for the solution, it works like a charm. The only problem I faced when tried to set my own API key is that mpsyt was throwing an error about invalid key or exceeded quota until I created an OAuth client ID. -- You are receiving this because you commented. Reply to this email directly or view it on GitHub: #1063 (comment)

@sokolgeo I agree with you 100%, and that is exactly what I am doing right now, using fake gmail account with tor proxy. Its getting really hard for non-technically minded people to maintain their privacy and anonymity. But I guess most of the users of mps-youtube are technical because normal people might use tor browser and will not use terminal based app to browse youtube.

@TalhaAkber
Copy link

Even with my own API, I have to delete ~/.config/mps-youtube/cache_py_3.6.9 every day, or it gives 403 error when starting.
pafy.util.GdataError: Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project 422897895433 before or it is disabled.

@Jeronimo17 yeah its a real pain, deleting this stupid cache on daily basis. That's why I added an extra command on my i3 config to remove the cache every time it starts.

@yumitsu
Copy link

yumitsu commented Mar 10, 2020

@TalhaAkber Also can be done with crontab task.

@benchile55
Copy link

Even with my own API, I have to delete ~/.config/mps-youtube/cache_py_3.6.9 every day, or it gives 403 error when starting.
pafy.util.GdataError: Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project 422897895433 before or it is disabled.

Happens the same issue still. I also need to remove cache.py files daily.

@DBX12
Copy link

DBX12 commented Mar 22, 2020

A workaround to removing the cache files is truncating them and then make them readonly. So the polluting API key cannot be written to the cache. I'm no Python dev so I cannot say how big the speed up by using the cache is but I did not feel a difference. For a Linux system, this should work:

echo -n '' > ~/.config/mps-youtube/cache_py_*
chmod 444 ~/.config/mps-youtube/cache_py_*

The downside is mpsyt complaining about the cachefile not being writeable and you cannot close the program with q anymore. Sending an Ctrl-D however still closes it without writing the cache file.

@ag-eitilt
Copy link

I'm going to use this as an excuse to point to NewPipe again -- their crawler doesn't go through YouTube's API so while they have to write everything themselves, they don't have the problems with quotas or things expiring. With that being in Java, it's obviously not just a drop-in replacement, but if things get to the point of rewriting the entire program, they could definitely be a source of inspiration and general guidance. Personally, I'm more likely to write my own desktop wrapper for that backend than I am to give Google direct access to my view data with an API key.

@seniorm0ment
Copy link

Please add the ability to use Invidious (and use Invidious logins), it should solve the API issue as well.
I am getting the issue on a fresh install of mps-youtube on Arch from base repos

@sebma
Copy link

sebma commented Mar 28, 2020

@ag-eitilt

I'm going to use this as an excuse to point to NewPipe again -- their crawler doesn't go through YouTube's API so while they have to write everything themselves, they don't have the problems with quotas or things expiring. With that being in Java, it's obviously not just a drop-in replacement, but if things get to the point of rewriting the entire program, they could definitely be a source of inspiration and general guidance. Personally, I'm more likely to write my own desktop wrapper for that backend than I am to give Google direct access to my view data with an API key.

Unfortunatly, there is no NewPipe for Linux yet : TeamNewPipe/NewPipe#1051

@atropo
Copy link

atropo commented Apr 16, 2020

Removing the mpsyt cache directory didn't worked for me.

But deleting the youtube-dl cache works fine, I do it with:

 youtube-dl --rm-cache-dir 

I'm using mpsyt on Ubuntu 18.04

@DBX12
Copy link

DBX12 commented Apr 18, 2020

@atropo I tried your approach but it was not successful. Are you sure you get the same error message / stack trace as the others in this issue?

@deliciouslytyped
Copy link

@ag-eitilt What about youtube-dl?

@atropo
Copy link

atropo commented Apr 22, 2020

@DBX12 Sorry, I forgot I have an automatic script that sets my personal api key on mpsyt on every startup

@annabham
Copy link

Of course, first I set my own API key:

mpsyt set api_key your_key

Deleting ~/.config/mps-youtube/cache* worked for a while, but I started getting 403 errors again today. Per @atropo I deleted the youtube-dl cache and then it started working.

This alias in my .bashrc should be handy:

alias tube='rm -f /home/anna/.config/mps-youtube/cache* && youtube-dl --rm-cache-dir && mpsyt'

Sure hope that finally fixes it, mpsyt has been great on a little low power 2008 netbook with lubuntu to listen to music while I work from home.

@DBX12
Copy link

DBX12 commented Apr 28, 2020

Nice alias @annabham 👍 but you could even go a step further and use a function to keep the name of the executable the same:

function mpsyt {
    rm -f /home/${USER}/.config/mps-youtube/cache*
# You might have to change these lines according to your install location
    /home/${USER}/.local/bin/youtube-dl --rm-cache-dir
    /home/${USER}/.local/bin/mpsyt
}

I'm not using ~ or ${HOME} so the path starts with the literal /home. Should the expansion of $USER fail for some reason, the path will be either invalid or point below the /home folder and no harm will be done to your system.

@surmish
Copy link

surmish commented May 2, 2020

What is the simplest resolution to this? And what does 'create a new application' mean here? I thought mps-youtube is a self contained application.

@trames57
Copy link

I had to do the same thing as AyoungDukie, I deleted my entire project at the Google Developers site and created a new one. I also tried refreshing the api key on the old project, but that did not work either. Creating a new project solved all issues. Even set api_key worked fine. I did need to remove the cache files in ~/.config/mps-youtube/cache* after I updated the api_key.
This is the link to delete and create projects (not easy to find!!)
https://console.developers.google.com/iam-admin/projects

@c64-dev
Copy link

c64-dev commented May 16, 2020

@trames57 solution should be upvoted as key to solving the issue.
In summary, in order to solve the issue you need to create your own API key and use it instead of the old default one.

  1. As per @trames57 solution, go to https://console.developers.google.com/iam-admin/projects and delete old project.
  2. Go to Library section and search for youtube data api v3.
  3. Click on the result and enable the library.
  4. Go to the Credentials section for your Project and click Create credentials to create a new API key.
  5. Copy API key and then in terminal issue the following:
    rm -f /home/${USER}/.config/mps-youtube/cache*
    mpsyt set api_key your_key
  6. The program will run and list all parameters. It should be showing your new API key. Exit and run again.

@sebma
Copy link

sebma commented May 19, 2020

@c64-dev

Go to the Credentials section for your Project and click Create credentials to create a new API key.

So now, each user of unofficial Youtube clients (mps-youtube,youtube-viewer,etc...) has to do that, right ?

If I understand what Google/Youtube are actually doing, it means there won't be anymore anonymous Youtube users anymore except for the the official Youtube client or apps using the NewPipeExtractor crawler API while it's still working for the time being.

It's a pity 😞.

@pt1997
Copy link

pt1997 commented May 19, 2020

@sebma

Unfortunatly, there is no NewPipe for Linux yet : TeamNewPipe/NewPipe#1051

the NewPipeExtractor was/is able to run on Linux TeamNewPipe/NewPipe#1051 (comment)

@catx0rr
Copy link

catx0rr commented Jun 21, 2020

1. Go to https://console.cloud.google.com, create a project, then enable Youtube Data Api V3 and create credential and get the API_KEY for public use.

2. Then remove the cache `rm ~/.config/mps-youtube/cache_py*`

3. Set the new api key `mpsyt set api_key YOUR_KEY_HERE`

4. Quit mpsyt (if there are any opened mpsyt instances"

5. Open it again and use it normally (it worked for me after following these steps)

Saved time on changing multiple api_keys on the configuration. thanks. I can confirm that this works.
2020-06-21_13-55

@conceptrat
Copy link

conceptrat commented Sep 24, 2020

I've been using my own API key for a while now with mps-youtube. Then recently it stopped working with the message about "invalid id or quota exceeded". I found that even if I hard coded the API key into the Pafy python library it didn't work. What finally worked for me was to create a new project, add the Youtube Data API to it and then create new Credentials to get the new API key.

Just as a side note I decided to set the restriction to just the Youtube API and not leave it as able to access all permissions. However both options worked.

@iamtalhaasghar
Copy link
Contributor

see #1191

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests