{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/921","repository_url":"https://api.github.com/repos/GoogleChrome/puppeteer","labels_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/921/labels{/name}","comments_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/921/comments","events_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/921/events","html_url":"https://github.com/GoogleChrome/puppeteer/issues/921","id":261844207,"number":921,"title":"userDataDir + headless = lost authorization","user":{"login":"vsemozhetbyt","id":10393198,"avatar_url":"https://avatars1.githubusercontent.com/u/10393198?v=4","gravatar_id":"","url":"https://api.github.com/users/vsemozhetbyt","html_url":"https://github.com/vsemozhetbyt","followers_url":"https://api.github.com/users/vsemozhetbyt/followers","following_url":"https://api.github.com/users/vsemozhetbyt/following{/other_user}","gists_url":"https://api.github.com/users/vsemozhetbyt/gists{/gist_id}","starred_url":"https://api.github.com/users/vsemozhetbyt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsemozhetbyt/subscriptions","organizations_url":"https://api.github.com/users/vsemozhetbyt/orgs","repos_url":"https://api.github.com/users/vsemozhetbyt/repos","events_url":"https://api.github.com/users/vsemozhetbyt/events{/privacy}","received_events_url":"https://api.github.com/users/vsemozhetbyt/received_events","type":"User","site_admin":false},"labels":[{"id":601668530,"url":"https://api.github.com/repos/GoogleChrome/puppeteer/labels/bug","name":"bug","color":"000000","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2017-09-30T13:34:02Z","updated_at":"2017-11-07T19:57:50Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"* Puppeteer version: v0.12.0-alpha\r\n* Platform / OS version: Windows 7 x64\r\n* URLs (if applicable): any that needs authorization\r\n\r\n1. Create a test script and an empty folder `test-profile-dir`:\r\n```js\r\n'use strict';\r\n\r\nconst puppeteer = require('puppeteer');\r\n\r\n(async function main() {\r\n  try {\r\n    const browser = await puppeteer.launch({\r\n      headless: false,\r\n      userDataDir: 'test-profile-dir',\r\n    });\r\n    const page = await browser.newPage();\r\n\r\n    await page.goto('https://twitter.com/');\r\n\r\n    console.log(await page.evaluate(() => document.title));\r\n    console.log(await page.evaluate(() => document.cookie));\r\n\r\n    // await browser.close();\r\n  } catch (err) {\r\n    console.error(err);\r\n  }\r\n})();\r\n```\r\nYou will see something like this:\r\n```console\r\nTwitter. It's what's happening.\r\n\r\npersonalization_id=...; guest_id=...; ct0=...\r\n```\r\nSign in into Twitter and type `Ctrl+C` to exit.\r\n\r\n2. Run the same script second time (`await browser.close();` can be uncommented). You will see something like this:\r\n```console\r\nTwitter\r\n\r\npersonalization_id=...; guest_id=...; ct0=...; ads_prefs=...; remember_checked_on=...;\r\ntwid=...; tip_nightmode=...; _ga=...; _gid=...; dnt=...; lang=...\r\n```\r\n3. Run the same script, but with `headless: true,` The output is the same as before authorization:\r\n```console\r\nTwitter. It's what's happening.\r\n\r\npersonalization_id=...; guest_id=...; ct0=...\r\n```\r\n\r\nI have tried various sites, all of them seem to lose authorization in headless mode.\r\n\r\nSome more notes:\r\n\r\n* `response.request().headers` does not contain cookies in both `headless: false` and `headless: true` modes.\r\n\r\n* `console.log(await page.cookies('https://twitter.com/'));` contains many cookies in the `headless: false` mode. In the `headless: true` mode it gives an empty array `[]`."},"comment":{"url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/comments/342603203","html_url":"https://github.com/GoogleChrome/puppeteer/issues/921#issuecomment-342603203","issue_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/921","id":342603203,"user":{"login":"JoelEinbinder","id":4624233,"avatar_url":"https://avatars1.githubusercontent.com/u/4624233?v=4","gravatar_id":"","url":"https://api.github.com/users/JoelEinbinder","html_url":"https://github.com/JoelEinbinder","followers_url":"https://api.github.com/users/JoelEinbinder/followers","following_url":"https://api.github.com/users/JoelEinbinder/following{/other_user}","gists_url":"https://api.github.com/users/JoelEinbinder/gists{/gist_id}","starred_url":"https://api.github.com/users/JoelEinbinder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoelEinbinder/subscriptions","organizations_url":"https://api.github.com/users/JoelEinbinder/orgs","repos_url":"https://api.github.com/users/JoelEinbinder/repos","events_url":"https://api.github.com/users/JoelEinbinder/events{/privacy}","received_events_url":"https://api.github.com/users/JoelEinbinder/received_events","type":"User","site_admin":false},"created_at":"2017-11-07T19:57:50Z","updated_at":"2017-11-07T19:57:50Z","author_association":"COLLABORATOR","body":"I can reproduce this on windows, although the test `headless should be able to read cookies written by headful` passes for me."}}
{"actor":{"display_login":"JoelEinbinder"}}