File size: 1,240 Bytes
e903a32 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
#!/usr/bin/env node
import { config } from 'dotenv';
import { Client } from '@notionhq/client';
// Load environment variables from .env file
config();
const notion = new Client({
auth: process.env.NOTION_TOKEN,
});
async function testAccess() {
const pageId = '27877f1c9c9d804d9c82f7b3905578ff';
try {
console.log('π Testing access to Notion page...');
console.log(`π Page ID: ${pageId}`);
const response = await notion.pages.retrieve({ page_id: pageId });
console.log('β
Access successful!');
console.log(`π Page title: ${response.properties.title?.title?.[0]?.text?.content || 'No title'}`);
console.log(`π
Created: ${response.created_time}`);
console.log(`π€ Created by: ${response.created_by.id}`);
} catch (error) {
console.error('β Access failed:', error.message);
if (error.code === 'unauthorized') {
console.log('\nπ‘ Solutions:');
console.log('1. Check that your NOTION_TOKEN is correct');
console.log('2. Make sure the page is shared with your integration');
console.log('3. Verify that the integration has the right permissions');
}
}
}
testAccess();
|