Closed Jozko568 closed 2 years ago
That is strange. The URL copy-pasted from the terminal is immediately redirecting to localhost? Would you try a different browser or a private tab? There were not any additional steps last time I set this up, but I know google likes to changes things for the fun of it.
No, it's not. This is the page after I authorize via Google. After I click Continue (by giving bbyen access to my account) I'm being redirected on this page above. I tried to open it in fresh Windows Sandbox environment, Firefox in Ubuntu but I ended up with the same result.
Recently I setup rclone which uses similiar authorization but I was redirected correctly as rclone stated Success. This seems like there is a missing server from bbyen which is required in order to get the code.
Unfortunately I can confirm this. I was unable to set it up. Seems like Google changed the authorization process and it no longer gives out the key to be copied. Is there any way that the code could be shown regardless?
Ok, I just tried it with a fresh installation and fresh Google cloud project. When I pasted the link and authorized and everything, I was indeed redirected to http://localhost
. I think the code
query parameter is what you need to paste in the terminal. Would you please try copy everything after (not including) localhost/?code=
up until the first &
, which for me is &scope=....
and paste that in the terminal?
Thanks! That works as a workaround.
Any plans to update the readme or the actual authorization process?
Also worth pointing out, it seems like gmail is no longer supported as per google changes mentioned here
[verbose] [videos]: New video from SometimesYouCom (id: AI0pgtw5-a4): Almost My Floor - PlayStation 5 / PlayStation 4 Release Trailer
[error] [videos]: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials z23-20020a170906435700b007094f98788csm6121655ejm.113 - gsmtp
Edit: I was able to set it up using App passwords
Everything seems to work, videos are being grabbed as expected. Thanks a lot.
Can confirm. Authorization works when using the code from the URL as you described.
Any plans to update the readme or the actual authorization process?
Yes, I might try to do it the "proper" way and have the local server answer that request and save the code. I just have to figure out why it's http://localhost
and not http://localhost:3030/some/path
. I might change the readme until then.
Glad it's working for you both
I did some more research. It seems like the old google-credentials.json
had the redirect_uris
to be urn:ietf:wg:oauth:2.0:oob
or localhost
. The former only showed the code, and the latter sends the request to localhost. I tried forcing the former, and I get a 400 invalid request response. I think Google discontinued this way. I am not sure why they did this. I see no security advantage. Maybe they just want to discourage the clunky "copy paste this code into the terminal".
The new proper and automatic method is in 55a04e1b. It automatically opens the browser tab, and opens a server to listen for the response code. Would either of you be willing to test the new method? If you use the same folder, you will have to delete .google-auth-token.json
. You also need to specify a port
in config.json
. I used 3030.
Hm, after tinkering with it in WSL, the URL gets opened automatically however the localhost is unreachable. As it no longer waits for code, I can't add it using the workaround. Not sure how this would work if the machine is headless?
Tried to run it with Node on my Windows 10 with Node v16 but I ended up with an error message below: I was able to fix it thanks to this thread.
After this I found another issue which is mentioned here I found that the port 3030 is excluded. Changing the port to something like 9200 worked and I was able to authorize automatically as per your latest commit. https://github.com/MarcelRobitaille/bbyen/commit/55a04e1b8e2fc952f2ab9b558b2ac8ce0544cb38
The strange thing is that after authorization I received this error message however bbyen continued to check the subscriptions. Not sure if it may cause some issues later on.
[info] [google-auth]: Got code: undefined
[info] [google-auth]: Creating tokens from code
TypeError: Cannot read properties of undefined (reading 'code')
at OAuth2Client.getTokenAsync (D:\Downloads\bbyen - Youtube Notify\bbyen2\node_modules\google-auth-library\build\src\auth\oauth2client.js:115:27)
at OAuth2Client.getToken (D:\Downloads\bbyen - Youtube Notify\bbyen2\node_modules\google-auth-library\build\src\auth\oauth2client.js:109:25)
at Server.handler (D:\Downloads\bbyen - Youtube Notify\bbyen2\src\google\auth\index.js:64:43)
at Server.emit (node:events:527:28)
at parserOnIncoming (node:_http_server:956:12)
at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)`
[verbose] [videos]: Checking channel TestChannel (UCMjg7arXVvaS5baey5mY2oA)
@NightMean sorry for the delay. Thanks for trying it!
As it no longer waits for code, I can't add it using the workaround. Not sure how this would work if the machine is headless?
That is a good point. I updated it so that both methods are supported. If the automatic method does not work, you can still paste into the terminal.
The strange thing is that after authorization I received this error message however bbyen continued to check the subscriptions. Not sure if it may cause some issues later on.
I got this once too, but I was not able to reproduce it after that. I suspect what happened is that two requests were made to localhost, and one failed (did not have any code or anything). Maybe the browser was trying to fetch /favicon.ico
or something. In my latest commits, I add checks and ignore any requests other than GET to /authorization_code
. That should stop such things from happening in the future.
I updated the documentation too to include this new authentication method.
I would like to hear what you think of these updates.
Thanks for the update! I did not have issues running it on my Windows machine, the auth code was automatically accepted (I used port 9020 again). However on my Linux headless VM I was unable to authorize. I tried to paste the whole URL (as per your commit https://github.com/MarcelRobitaille/bbyen/commit/8d1b290b834f729e6b456788d923b14630a58cf7) and then only the code as previously but I received the same error message in both cases.
Enter the code from that page: 4/0AdQt8qgVUUzQR81knYpCeD2zT1I_haFus6QeNJgtF78nVgAeqKMUxDV6pBeog1Nf4W7C7A
[error] [main]: Cannot use 'in' operator to search for '&' in 4/0AdQt8qgVUUzQR81knYpCeD2zT1I_haFus6QeNJgtF78nVgAeqKMUxDV6pBeog1Nf4W7C7A
^C
On another note, I received error invalid_grant
on my second Google project, will reopen issue https://github.com/MarcelRobitaille/bbyen/issues/7
Currently, I'm not able to test emails as I have to wait until Google actually removes my previous projects.
I've been doing too much Python. That error should be fixed. Not sure how I didn't catch it.
I'll check out that other issue for invalid_grant
.
May I ask why you're running this twice? Is it for two different YouTube accounts?
I've been doing too much Python. That error should be fixed. Not sure how I didn't catch it.
Thanks for the quick fix! Pasting the URL still throws an error message, but different this time. Pasting just the code works like a charm now!
[error] [main]: url.parse is not a function
May I ask why you're running this twice? Is it for two different YouTube accounts?
No it's not for 2 Youtube accounts. I guess I'm just the type of a person who likes to have it working on all environments haha. (Somebody has to catch all the bugs, right?) I run it primarily on my Linux VM but I tried to run it on my Windows just for test.
[error] [main]: url.parse is not a function
Sorry about that. Another stupid mistake. Should be fixed now.
Works like a charm now! Links and code is now accepted as expected!
Perhaps a small improvement would be to change the text that is displayed after the auth URL. Enter the code from that page:
to something like Paste whole URL after authorization
or something like that which is understandable.
Other than that I only found 1 major issue. I did not find any way to donate! May I request a fix for this?
Wow. That's never come up before. Thank you very much. It's very kind. I am willing to set up donations. What would you prefer? Paypal, GitHub sponsors, bitcoin? I would also be happy if you donated to another open source project as well.
I will think about changing that string.
I changed it to Paste the entire URL of the page you are redirected to (even if you receive 404):
. What do you think?
Wow. That's never come up before. Thank you very much. It's very kind. I am willing to set up donations. What would you prefer? Paypal, GitHub sponsors, bitcoin? I would also be happy if you donated to another open source project as well.
I will think about changing that string.
I prefer PayPal if that's okay. I already donated to couple 😁
I changed it to
Paste the entire URL of the page you are redirected to (even if you receive 404):
. What do you think?
Yup, sounds better to me! Thanks!
I added my paypal link to the readme. Thank you very much @NightMean. You don't have to donate anything.
Do you think we can close this?
Thanks to you I can keep my Youtube obsession for longer haha! Sure, we can close it.
Thanks for the quick fixes! 👍
Hi, I'm trying to set this up but whenever I try to run
node src/index.js
and authorize via the given URL, I'm being redirected to non working page where the code should be displayed. I noticed that the URL containshttp://localhost
from thegoogle-credentials.json
file but even if I try to change it to a different address or specify any port, the page never loads. I do not have any service running on port 80 so that should not be an issue. Google credentials are setup as desktop app.I tried to authorize on Windows (also in Windows Sandbox) and Ubuntu but I got the same result. Is there some step which is not mentioned in the readme?
Node version:
v16.15.1