Rob--W / cookie-manager

Cookie Manager for Firefox (Desktop/Android), Chrome. Supports viewing and editing of cookies and private cookies.
Mozilla Public License 2.0
105 stars 24 forks source link

Cannot Import into Chrome #36

Open OllyHill opened 4 years ago

OllyHill commented 4 years ago

Hello Mate, hoping for some help. I am unable to import JSON cookies into Chrome 83.0.4103.61 (Official Build) (64-bit). As an example, the following format does not import and gives the error "ERROR: Failed to import: unrecognized format"

[
{

    "domain": ".microsoft.com",
    "expirationDate": 13263742881229765,
    "hostOnly": false,
    "httpOnly": false,
    "name": "MC1",
    "path": "/",
    "sameSite": "no_restriction",
    "secure": false,
    "session": false,
    "storeId": "0",
    "value": "GUID=7811bdf3a5d540a6830456e4bae00128&HASH=7811&LV=202004&V=4&LU=1587733279030",
    "id": "174"
}
]

I am unclear what is wrong with this format.

Thanks mate for any help.

Rob--W commented 4 years ago

This is not what my extension generates - where did you get those cookies and why did you expect the import to succeed?

The bare minimum to get it to work is as follows:

{"cookies": <paste array from your comment here>}

For those who can read code, the export logic is here: https://github.com/Rob--W/cookie-manager/blob/e28a7732929a8a7b45813bc476815871d56d3aab/cookie-manager.js#L885-L904

and the import logic is here: https://github.com/Rob--W/cookie-manager/blob/e28a7732929a8a7b45813bc476815871d56d3aab/cookie-manager.js#L905-L928

OllyHill commented 4 years ago

This is not what my extension generates - where did you get those cookies and why did you expect the import to succeed?

The bare minimum to get it to work is as follows:

{"cookies": <paste array from your comment here>}

For those who can read code, the export logic is here: https://github.com/Rob--W/cookie-manager/blob/e28a7732929a8a7b45813bc476815871d56d3aab/cookie-manager.js#L885-L904

and the import logic is here: https://github.com/Rob--W/cookie-manager/blob/e28a7732929a8a7b45813bc476815871d56d3aab/cookie-manager.js#L905-L928

Yes mate, I see now. Thanks for explaining that to me.

On another note, I've been having trouble copying my google cookies. I'm on Windows 7 running Chrome version 83.0.4103.61 (Official Build) (64-bit).

I export all cookies (do not use filter in the extension) to JSON. I create a new profile on the same machine and add your extension (use developer tools to load unpacked extension). I import the JSON file and am not logged into gmail or my google account. Sometimes mate, I'm actually logged out of my original profile. Not sure what is going on or if I buggared it up when importing.

Rob--W commented 4 years ago

Are you able to reproduce with a new browser profile in Chrome? If yes, are you able to reproduce if you test an export from Firefox to another Firefox profile?

OllyHill commented 4 years ago

Yes I am. These are the scenarios I tested:

1) Chrome version 83.0.4103.97 (64 bit) My main profile is named Olly. I exported cookies in the netscape format. I created a new profile called Test. I installed your extension (enabled developer mode, deleted all pre-existing cookies). I imported the netscape cookie file and received a notification that 1 cookie was not imported because it expired. I went to google.com and I am not logged in. I went to gmail and still am not logged in. I switched windows back to my original profile named Olly (which is opened this entire time ) and now I am logged out.

2) Firefox version 77.0.1 (64 bit) I carried out the exact same process as above. I exported a brand new netscape cookies file from my main profile. I created a new profile in Firefox, imported the cookies files and received one error that a cookie expired, but everything works. I go to google.com and I am logged in already.

3) Chrome -> Firefox As a third test, I created a new profile in Firefox, installed your add-on from Mozilla, and imported the Chrome netscape file this time. I went to google.com and was not automatically logged in. I clicked gmail and was brought to the sign in page. Interestingly, my account was listed already but it said "signed out." When I clicked my name, I received an error from google and was instructed to clear my cookies.

Rob--W commented 4 years ago

Ah. Do not use the netscape format, but the JSON format. The JSON format is a full copy, the Netscape format doesn't support the SameSite flag (which could explain some cookie loss).

I've just pushed a change to master (1c1f390) to recognize the difference between SameSite=None and unspecified. This helps with importing Chrome's cookies in Firefox (because Firefox's extension API doesn't support unspecified SameSite yet - https://bugzilla.mozilla.org/show_bug.cgi?id=1550032), AND it also allows you to change the default SameSite flag in Chrome (Chrome 84 will change the default behavior for SameSite, which may cause more breakage. My extension can be a way to fix the SameSite flag of a cookie).

Could you pull from master and retry, with the JSON format instead of Netscape?

OllyHill commented 4 years ago

Thanks for the help mate. I pulled the latest master and it's still happening. I'm conveying detailed steps I took for the sake of completion:

Windows 7 64-bit Chrome Version 83.0.4103.97 (Official Build) (64-bit)

-On my main profile called Olly, I did the following- 1) Downloaded latest zip from master and unzip to desktop 2) Go to extensions, turn on developer mode and load extension using "load unpacked" 2) Extension immediately opens. In the "filter by url or domain" search box I use "*.google.com" 3) I click "search cookies" 4) I click "Select all" which highlights several cookies in yellow 5) I scroll down to the bottom of the search results and continue to click the "Show XX more rows" button. I do this because I am unable to export cookies if all the cookies are not shown. 6) I click "Export selected cookies" using options "JSON" and "Export as file" selected

-I create a brand new Chrome file called "Test"- 1) Go to extensions, turn on developer mode and load extension using "load unpacked" 2) Extension immediately opens. I click "Import Cookies" 3) I click "Choose File" and select the cookies.json file that was exported from my main profile 4) I click import and all 48 cookies are imported without error (this was different from the my last post which always gave me a parsing error for a few cookies). 5) I open a new tab and go to google.com. I am not logged in. 6) I go to my previous Olly profile which is still open in a separate window. I click refresh while on the google.com website. I am now logged out. I click the gmail at the top right and receive an error saying my account is temporarily unavailable. 7) This website has a link to "sign out." I click this link and then sign in again.

Again, thanks for the help mate. I can understand if transferring cookies to a new profile does not work, but what's mind boggling is I am logged out of my original profile on the same exact computer system. It's almost like Google or Chrome security is preventing this from happening. I'm sure I'm buggaring it up, but I have no slight clue what I'm doing wrong.

Rob--W commented 4 years ago

I scroll down to the bottom of the search results and continue to click the "Show XX more rows" button. I do this because I am unable to export cookies if all the cookies are not shown.

Oops. Thanks for mentioning this. The fact that you had to click so many times is a bug. It should have been possible to select the row itself (by clicking besides the button) to select all cookies covered by that row. I just pushed a commit to master to fix that (84af251).

Are you able to verify the bug with a completely new profile, in Chrome -> Chrome, and separately Firefox -> Firefox? I vaguely recall that Google added some extra features to Chrome to allow them to enforce stricter authentication, hence asking for STR between Firefox and Firefox.

I want to try to reproduce your bug, and would like to do that from a clean profile. Could you be more explicit on where I need to sign in (e.g. Gmail) to generate the cookies for the test?

OllyHill commented 4 years ago

Oops. Thanks for mentioning this. The fact that you had to click so many times is a bug. It should have been possible to select the row itself (by clicking besides the button) to select all cookies covered by that row. I just pushed a commit to master to fix that (84af251).

Thanks mate. I just pulled the new master. The bug fix makes exporting cookies so much easier now.

Are you able to verify the bug with a completely new profile, in Chrome -> Chrome, and separately Firefox -> Firefox? I vaguely recall that Google added some extra features to Chrome to allow them to enforce stricter authentication, hence asking for STR between Firefox and Firefox.

On Chrome, I created 2 new profiles called "Testing_1" and "Testing_2". On Testing_1, I installed the extension logged into gmail, and exported cookies in JSON.

I left the window for Testing_1 open and opened the new profile for Testing_2. I installed the extension and successfully imported the JSON cookies from the profile called Testing_1. I go to google.com and I am still not logged in. I switch back to the window with the Testing_1 folder and hit refresh on google.com. I am no longer logged in.

I conducted the same test in Firefox with 2 fresh profiles and this does not happen. Both profiles stay logged in and everything works.

I want to try to reproduce your bug, and would like to do that from a clean profile. Could you be more explicit on where I need to sign in (e.g. Gmail) to generate the cookies for the test?

I usually go to google.com and click the "Sign In" button in the top right corner. Or sometimes I click the gmail link ad sign in that way. Either way, I'm going to google.com. In fact, if you are logged into google and go to google.com, then an icon is added to the homepage. Here are 2 screenshots below my actual testing using Chrome. The first screenshot is Testing_1 which is signed in. The second screenshot is Testing_2 after I import the cookies. I am expecting to be signed into google after the import, but I am not. I circled the "Sign In" button which is actually be replaced with the icon O like in the first screenshot.

logged_in logged_out

One quick point mate, this issue of being logged out only applies to google which is why I think they have an extra layer of security built into Chrome and google accounts, but I am entertaining my imagination at this point. I do not have the same issue with instagram. Thanks again for all the help.

Rob--W commented 4 years ago

I can't reproduce the problem in Chromium. I created a new profile, visited google.com and logged in. I noticed that I'm not only logged in in the website, but also in the browser. I exported all *google.com cookies as JSON. I created another new profile (not with Chrome's accounts/profile feature, but actually with a new directory passed to --user-data-dir), imported the cookies and visited google.com and Gmail. In both cases, I'm still logged in.

There used to be a command-line flag (--account-consistency) to disable this, but it appears to have been removed from Chrome, with no intent to return it: https://bugs.chromium.org/p/chromium/issues/detail?id=954337

Could you visit chrome://settings/syncSetup , disable "Allow Chrome sign-in" and see if it resolves the issue?