Last active
June 22, 2021 22:31
-
-
Save nmcclain/30e4f5ee231e606bc4a1dcedef1c551f to your computer and use it in GitHub Desktop.
Get Notion.so token_v2 with username/password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DANGER: Run this too frequently and you can lock out your Notion account. | |
// Once a day should be sufficient for most use cases. | |
// | |
// npm i -D playwright | |
// export NOTION_TOKEN=`node gettoken/gettoken.js` | |
const { chromium } = require('playwright'); | |
const user = 'XXXX'; | |
const pass = 'YYYY'; | |
(async () => { | |
const browser = await chromium.launch({ headless: true, slowMo: 50 }); | |
const ctx = await browser.newContext(); | |
const page = await ctx.newPage(); | |
await page.goto('https://www.notion.so/login'); | |
await page.fill('#notion-email-input-1', user); | |
await page.click('text=Continue with email'); | |
await page.fill('#notion-password-input-2', pass); | |
await page.click('text=Continue with password'); | |
await page.waitForSelector('div.notion-sidebar'); //, { state: 'attached' }); | |
const cookies = await ctx.cookies(['https://www.notion.so/']); | |
for (const cook of cookies) { | |
if (cook.name == 'token_v2') { | |
console.log(cook.value); | |
} | |
} | |
await ctx.close(); | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment