Skip to content

Instantly share code, notes, and snippets.

Last active Jun 22, 2021
What would you like to do?
Get token_v2 with username/password
// 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('');
await page.fill('#notion-email-input-1', user);
await'text=Continue with email');
await page.fill('#notion-password-input-2', pass);
await'text=Continue with password');
await page.waitForSelector('div.notion-sidebar'); //, { state: 'attached' });
const cookies = await ctx.cookies(['']);
for (const cook of cookies) {
if ( == 'token_v2') {
await ctx.close();
await browser.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment