Spaces:
Paused
Paused
| import { config } from 'dotenv'; | |
| import { resolve } from 'path'; | |
| const __dirname = new URL('.', import.meta.url).pathname.replace(/^\/([A-Z]:)/, '$1'); | |
| config({ path: resolve(__dirname, '../.env') }); | |
| import { createShowpadAuthFromEnv } from '../src/services/showpad/showpad-auth.js'; | |
| async function main() { | |
| console.log('Testing Showpad with existing auth service...\n'); | |
| console.log('Subdomain:', process.env.SHOWPAD_SUBDOMAIN); | |
| console.log('Username:', process.env.SHOWPAD_USERNAME); | |
| console.log('Password:', process.env.SHOWPAD_PASSWORD ? '***' : '(missing)'); | |
| console.log(''); | |
| try { | |
| const auth = createShowpadAuthFromEnv(); | |
| console.log('Attempting authentication...'); | |
| await auth.authenticate(); | |
| const state = auth.getState(); | |
| console.log('✅ Authentication successful!'); | |
| console.log(' Token expires:', new Date(state.expiresAt!).toISOString()); | |
| console.log(' Scopes:', state.scope.join(', ')); | |
| // Try to fetch some assets | |
| console.log('\nFetching assets...'); | |
| const assets = await auth.request<{items: any[]}>('/assets?limit=5'); | |
| console.log('✅ Fetched ' + assets.items.length + ' assets'); | |
| for (const asset of assets.items) { | |
| console.log(' - ' + asset.name + ' (' + (asset.mimeType || 'unknown') + ')'); | |
| } | |
| } catch (error: any) { | |
| console.error('❌ Error:', error.message); | |
| } | |
| } | |
| main(); | |