Skip to main content
Glama
exchange-code.ts1.04 kB
import * as auth from './auth.js'; import { createInterface } from 'readline'; const rl = createInterface({ input: process.stdin, output: process.stdout }); async function exchangeCode() { try { // Prompt for authorization code and code verifier const code = await new Promise<string>((resolve) => { rl.question('Enter the authorization code from the redirect URL: ', resolve); }); const codeVerifier = await new Promise<string>((resolve) => { rl.question('Enter the code verifier from the previous step: ', resolve); }); // Exchange code for tokens const tokens = await auth.exchangeCodeForTokens(code.trim(), codeVerifier.trim()); console.log('\nSuccess! Tokens have been saved.'); console.log('Access token expires at:', new Date(tokens.expiresAt).toLocaleString()); console.log('Scopes:', tokens.scope.join(', ')); } catch (error) { console.error('\nError exchanging code for tokens:', error); } finally { rl.close(); } } exchangeCode().catch(console.error);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/amgadabdelhafez/dbx-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server