browser-extension icon indicating copy to clipboard operation
browser-extension copied to clipboard

Cookie import fails with "validated: undefined"

Open EpicLPer opened this issue 1 year ago • 15 comments

Heya,

I just tried importing my cookies and I'm getting the following error inside the browser extension: image

In the Inspect tab I get the message {"message":{"cookie_import":"fail","cookie_validated":false}}, the network tab tells me a 400 Bad Request occured.

Not sure if I'm doing something wrong (again) tho :)

Thanks already!

EpicLPer avatar Aug 14 '23 21:08 EpicLPer

Impossible to say without logs what's happening. Probably means invalid cookie? Sometimes doing this from a blank browser can help, where there has always only been one google account used. Or you can also use the manual import.

bbilly1 avatar Aug 17 '23 01:08 bbilly1

I have the same issue, have been having it since forever and always just manually added the cookie, very annoying. This is the log from when I tried to add the cookie using the extension:

cookie preview:

# Netscape HTTP Cookie File
# https://curl.haxx.se/rfc/cookie_spec.html
# This is a generated file! Do not edit.

.youtube.com    TRUE    /       FALSE   1719579328      SOCS    [REDACTED]
.youtube.com    TRUE    /       TRUE    0       YSC     [REDACTED]
.youtube.com    TRUE    /       FALSE   1720011328      CONSENT [REDACTED]
.youtube.com    TRUE    /       TRUE    1725
cookie: activated and stored in Redis
validating cookie
cookie file is invalid
cookie validation failed, exiting...
cookie: revoked
cookie: {'cookie_import': 'fail', 'cookie_validated': False}
[pid: 44|app: 0|req: 1359/1359] 10.0.0.38 () {64 vars in 1070 bytes} [Thu Aug 17 14:16:03 2023] PUT /api/cookie/ => generated 61 bytes in 101 msecs (HTTP/1.1 400) 9 headers in 357 bytes (1 switches on core 0)

It seems to just send bad data, not actually the full cookies file like it needs.

DutchEllie avatar Aug 17 '23 12:08 DutchEllie

A cookie is valid, if TA can access your liked videos playlist, e.g. https://www.youtube.com/playlist?list=LL. If it can't access that, it's invalid and revoked as you can see in your output.

One of these cases of works on my machine. If it doesn't work for you, please provide a fix.

bbilly1 avatar Aug 17 '23 12:08 bbilly1

very annoying

Please be nice.

bbilly1 avatar Aug 17 '23 12:08 bbilly1

I had the same issue.

screenshot1

I compared the original cookies stored in the browser, and it seems that TubeArchivist did not receive the last 54 characters in the cookie value.

image

grantterra avatar Sep 03 '23 10:09 grantterra

I'm also experiencing this issue for months now.
It did work as expected back in June and then suddenly failed.
Tubearchivist on my server, as well as the browser extension, are on the newest versions.
I have deleted all my YouTube cookies, did a fresh login - also no success.

I'm using LibreWolf Firefox 118.0.1-1 on Linux 6.5.5-arch1-1

Edit: I can confirm the observation by grantterra, the cookie extracted by the extension is too short. After exporting the cookie manually, placing it in the import directory, enabling cookies and reindexing, my playlist it is active again.

3urobeat avatar Oct 08 '23 13:10 3urobeat

I'm experiencing this in Chrome, but not in Firefox.

clb92 avatar Oct 14 '23 15:10 clb92

It seems to just send bad data, not actually the full cookies file like it needs.

and

I compared the original cookies stored in the browser, and it seems that TubeArchivist did not receive the last 54 characters in the cookie value.

as well as

I can confirm the observation by grantterra, the cookie extracted by the extension is too short.

you'll see in your log output cookie preview. so what is logged is only the first 200 characters (I think) from the complete cookie. as that is sensitive data, so this shouldn't be logged completely somewhere...

cookie building happens in background.js here: https://github.com/tubearchivist/browser-extension/blob/master/extension/background.js#L209

if anybody wants to investigate further.

bbilly1 avatar Oct 19 '23 05:10 bbilly1

Some investigation on the live stream could point towards that we limit our domain selection too much, and that www.youtube.com will get excluded.

notes: https://github.com/Rob--W/cookie-manager/issues/26

some traceback:

/usr/local/lib/python3.11/http/cookiejar.py:2083: UserWarning: http.cookiejar bug!
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/http/cookiejar.py", line 2056, in _really_load
    assert domain_specified == initial_dot
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

  _warn_unhandled_exception()

bbilly1 avatar Nov 10 '23 02:11 bbilly1

For me, looks like the extension included a cookie from the subdomain payments.youtube.com and yt-dlp is not happy with that. Removing it from the POST /api/cookie/ works.

Because the validation is done by yt-dlp, before https://github.com/tubearchivist/tubearchivist/pull/669 which would log the error in the console, you could try capturing the cookie file sent by the extension from the extension developer console, then testing it with downloading any youtube video with a noop arg like -F, then it would give error like:

http.cookiejar.LoadError: invalid Netscape format cookies file 'C:\\Users\\<user>\\Desktop\\cookies.txt': 'payments.youtube.com\tTRUE\t/\tFALSE\t1711779732\tOTZ\t<some-value>'

Gentoli avatar Mar 01 '24 06:03 Gentoli

Interesting, would make sense that I can't reproduce this, I probably won't have any payment subdomain cookies if I didn't make any payments on YT. Will ignoring all subdomains work? Or does this need some other processing?

bbilly1 avatar Mar 10 '24 15:03 bbilly1

Given yt-dlp is rejecting cookies from the subdomains, I think it's safe to remove all subdomains.

Gentoli avatar Mar 10 '24 23:03 Gentoli

I do not have any cookies on subdomains but it still fails. Both on firefox and chrome and with different accounts

CommanderRedYT avatar Mar 26 '24 11:03 CommanderRedYT

I can confirm that removing the payments.youtube.com cookie solved the problem for me.

wolrah avatar Mar 27 '24 20:03 wolrah

Can somebody who can reproduce this check if the linked commit on the https://github.com/tubearchivist/browser-extension/tree/fix-cookie-domain branch fixes that?

This still syncs the cookie correctly for me.

bbilly1 avatar May 01 '24 20:05 bbilly1

assuming this has been fixed, update to v0.3.0

bbilly1 avatar May 11 '24 15:05 bbilly1