#!/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();