hallzy / youtube-playlist-search

A Chrome Extension to search Youtube Playlists for Videos
71 stars 7 forks source link

This extension is not working due to access token not being acquired... #5

Closed Linden10 closed 2 years ago

Linden10 commented 2 years ago

Hi, I'm having trouble using this extension to search playlists as it's not working for some reason...

Every time I try to use the extension, no matter how many times I allow access to my youtube account...the extension does nothing and just get 0/0 matches.

I tried this on many playlists I have, still the same results. It's also happening with the official extension you forked too!

I inspected the extension's window and noticed that in console, I got an 401 error trying to access the youtube api and noticed that the access token was "undefined" in the url.

For some reason, the extension is not acquiring the access token that I'm allowing it to use. I'm not sure why and thus I came here to report the problem.

If you can check and see what might be the cause...then that'll be great! Thank you!

I'm using the latest version of google chrome, ver. 95.0.4638.54 (Official Build) (64-bit), on windows 10 by the way! Also of note, I notice three errors that appear on the extension in the extension manager:

Context _generated_background_page.html Stack Trace js/popup.js:1 (anonymous function)

"Uncaught SyntaxError: Cannot use import statement outside a module" (Might be not an issue but wanted to mention) import spinner from './objects/spinner.js';

Unchecked runtime.lastError: The user did not approve access. (I clicked allow every time I choose my account but for some reason, it's not working!) Unchecked runtime.lastError: The user is not signed in.

hallzy commented 2 years ago

Congratulations @Linden10, you have managed to stump me here ;)

I haven't had a thorough look at this yet but what you are reporting is truly weird and not reproducible on my end.

Based on the error 401 that you say the api gives you my initial guess would be bad credentials...

I hate to be that guy, but just make sure you are providing the correct credentials for your account.

The Cannot use import statement outside a module error is total nonsense to me since all the javascript is in a module, so how that has come up I am not sure.

It is late where I live, so I will have a more in depth look tomorrow and try to get to the bottom of this.

Is there any playlist that this does work for or is it just all broken for you? Would you be able to provide a URL to one of the playlists that isn't working just so I can rule out the issue being with particular playlists?

One last thing that comes to mind is do you have something that may be blocking the youtube api request to googleapis.com (firewall, vpn, ad blocker, other chrome extensions, etc)?

Linden10 commented 2 years ago

Actually I had already re-logged into my google account and even sign-out and sign-in into my youtube account but still had the same errors...

As for blocking the youtube api...I have ublock but it's not blocking the api to my knowledge. In the past I was able to use the official "playlist search" extension without issue too even with ublock...

I just tested the extension without ublock on and it still doesn't work so that rules it out.

Weird how both the official and your extension aren't working, even checking the reviews for the official extension on the chome store shows people saying it's not working anymore. (Looks like it started sometime ago...well it wasn't updated in a year so there's that.)

Anyways here's one of my playlists I used it on that's not working: (Big Playlist, one I add a lot to and love): https://www.youtube.com/playlist?list=PLK-AD3aofCq_6KTZ3hFrWm2SpMzT5nu1q

and another one (very small playlist): https://www.youtube.com/playlist?list=PLK-AD3aofCq_89Z2z5H30f4Z6oJSbArrF

Hopefully there's a way to fix this problem!

hallzy commented 2 years ago

pff rookie mistake. The cannot use import statement outside a module was fixed by an uncommitted change on my computer 🤦

I don't think that will fix your problem, but it should at least get rid of that error. I've pushed it now (5c50bc4b627976474997f0f6c39235b2452372a2). You may as well try it and see if that fixes the problem... You can just pull the change into the repo and reload the extension (images below to help find he reload button)

region-20211025-233139

region-20211025-233152

Let me know how that goes, and I'll have another look tomorrow.

I just tried your big playlist and it works for me, so definitely not specific to the playlists you are using.

Linden10 commented 2 years ago

Ha I see you already fixed that small problem, cool! I installed it and while that error is gone, I'm still unable to search any playlist which is a shame.

I really don't know why it's not working... Thanks for helping and hopefully you can find a solution if possible!

hallzy commented 2 years ago

Okay, I think I know what your problem is, and I was able to reproduce it. That is the good news...

The bad news is that this is not going to be quick.

I think I was using the client id in the manifest from the extension that is on the chrome web store, so when that one died mine died with it I think... but obviously not for everyone because I could still use it.

I created my own client ID now, and tried that and it still worked for me, but then noticed it was on testing mode. I changed it to production and I had to fill out a whole verification form and now I am getting a similar error as you.

It says that verification will take 4 to 6 weeks, and to be honest, I am not expecting it to go through because I don't have it on the web store in the first place.

I'll have to try and figure something out... Not really sure how to move forward from here.

If you want to use this extension now you could create your api credentials. If you want to do that you should be able to just go here: https://console.cloud.google.com/apis/library/youtube.googleapis.com, enable the youtube api on your account, and setup credentials (there should be a 'Credentials' link in the left bar and after you click on that the page should have something like "Create Credentials"... Select the OAuth Client ID credential type and fill out the form

hallzy commented 2 years ago

Actually, you could try the new code... While it is not verified it should still work for up to 100 users

Linden10 commented 2 years ago

AH so that's why it wasn't working this whole time! Nice that you found the problem and I understand how long it'll take too!

I'm more then willing to wait til you're verified...hopefully. Oh and I know about creating api credentials as I made one for myself sometime last year, though I don't have oautth one created though...so I'll wait!

But I'll check the new code out you posted in the meantime. Thank you for taking the time to look into this and helping out!

hallzy commented 2 years ago

I found the issue tracker for the YouTube Data API, which is the API I use here... I'll see if I can gather more information and submit a ticket with them.

Something still seems off because I can use the extension on my personal laptop, but logged in with the same account on my work laptop doesn't work. If it is an issue with verification etc, the fact that it works on chrome using the same account on 2 different computers doesn't make sense to me

¯\_(ツ)_/¯

hallzy commented 2 years ago

Sorry to keep commenting here... Just had another update...

I pushed a new change which changes the client id again. I noticed while looking at the developer console that the api quota per day limit was 0. I don't know how that is even possible, but that would certainly explain why it wasn't working.

Try pulling that and retrying... Maybe even try logging out of the browser, closing the browser and removing the extension altogether, and then re-add it back just in case the browser decides to cache something.

I suspect that if when you login it will pop up saying something like unverified app or something, since this client id is not verified either (I literally just created it). Make sure to actually ignore the warning and continue instead of "Going back to safety" or whatever phrasing google uses

Let me know how that one goes...

Linden10 commented 2 years ago

It's okay, you're the one helping so I don't mind how many comments you make! Also I'll download the new commit, I actually haven't opened chrome and tested the last ver. yet so it's a-okay for me to use without having to re-login!

Hopefully this works out well!

Linden10 commented 2 years ago

I'm getting an timeout message every time I try to use the extension and allow access. Basically I get timed out before I finish allowing access to my account, giving me a "Timeout: Failed to retrieve auth token" message every time I do.

Basically it's not waiting long enough for me to finish... Not sure what to do.

Oh and I notice the change to the new client id you've put in, where every time I try to allow access I get a "it's not verified yet" message but it still works as I can continue on from it.

Still if the extension didn't time out too soon, I might've been able to use it...might.

hallzy commented 2 years ago

@Linden10 I just pushed another change to remove the timeout. let me know if that helps.

hallzy commented 2 years ago

@Linden10 Haven't heard from you in a few days. Just wondering if you've tried since I removed the timeout

Linden10 commented 2 years ago

Oh I forgot to tell you, the timeout is gone but I get the "Error: couldn't retrieve YouTube API Auth Token" instead after allowing access.

Not sure why it can't get it...

hallzy commented 2 years ago

Are you still getting the Unchecked runtime.lastError: The user is not signed in. error as well? Or is there a different lastError message now.

If you can get me that message and any other errors that come up in the console, I'll see if that might help, and if not I'll see if I can open a ticket with the Google API team, because if their system won't give you a token there is not an awful lot that I can do.

I can see in the google developer console that other people are using the extension so there are other people that definitely aren't having this same issue for whatever reason.

If you are able as well, if you could add a console.log or something to see what the token is that google is returning that would be useful too... Basically, find this code in populatePopup.js:

        const token = await getAuthToken();

        if (!token) {
            throw Error("couldn't retrieve YouTube API Auth Token");
        }

and change it to something like:

        const token = await getAuthToken();
        console.log("Received Auth Token:", token);

        if (!token) {
            throw Error("couldn't retrieve YouTube API Auth Token");
        }
hallzy commented 2 years ago

Or, if you want you could open the ticket with the data api team, which might be better since you'd be able to give them information quicker: https://issuetracker.google.com/issues?q=componentid:186600

Linden10 commented 2 years ago

Oh my gosh...I just figured out the problem I was having all along in getting the extension to work...

All this time I was trying to allow access using my "youtube account" and not my google account! So when the window pops up, I have like three accounts which are two youtube accounts (2nd one I don't use anymore) and one that's my google/gmail account. (I never used the third one).

Under the name of my accounts it shows "youtube" or "example@gmail.com" and all this time I was trying to get my main youtube account to allow access to no avail.

So I decided to try the account with my email under it and lo and behold it works! I didn't know that you had to choose not the youtube account but the one with your email under it!

Thanks for helping me out thus far, I don't see any errors after signing in but I encounter anything I'll tell you! If you have questions, feel free to ask!

Happy Halloween and thanks hallzy!

hallzy commented 2 years ago

Good to hear :) I will close this for now then since it seems to be working for you