Skip to main content
Glama
test-oauth-with-env-creds.cjs4.45 kB
#!/usr/bin/env node /** * Test OAuth server with the test credentials from .env */ const axios = require('axios'); async function testOAuthWithEnvCreds() { // Use test credentials from .env const username = 'elisha@umbrellacost.cloud'; const password = '6K2UX6DoYSgV%E'; console.log('\n🔐 Testing OAuth Server with Known Working Credentials'); console.log('=' .repeat(60)); console.log(`Username: ${username}`); console.log(`Password: ${'*'.repeat(password.length)}`); console.log('=' .repeat(60)); // Test 1: Direct API authentication console.log('\n1️⃣ Testing direct API authentication:'); try { const response = await axios.post( 'https://api.umbrellacost.io/api/v1/authenticate', { username, password }, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' } } ); console.log('✅ Direct API auth successful!'); console.log('Headers received:', { Authorization: response.headers.authorization ? 'Present' : 'Missing', apikey: response.headers.apikey ? 'Present' : 'Missing', }); } catch (error) { console.log('❌ Direct API auth failed:', error.response?.status, error.response?.statusText); } // Test 2: OAuth server authentication console.log('\n2️⃣ Testing OAuth server (localhost:3000):'); // First, get a session by initiating OAuth flow try { // Step 1: Initiate authorization const authUrl = 'http://localhost:3000/oauth/authorize'; const params = new URLSearchParams({ response_type: 'code', client_id: 'claude-desktop', redirect_uri: 'http://localhost:3000/callback', state: 'test-state', code_challenge: 'test-challenge', code_challenge_method: 'S256' }); console.log('Initiating OAuth flow...'); const authResponse = await axios.get(`${authUrl}?${params}`, { maxRedirects: 0, validateStatus: (status) => status === 302 || status === 200 }); if (authResponse.status === 302) { console.log('✅ Redirected to login page (expected)'); // Step 2: Submit credentials to login endpoint console.log('Submitting credentials to OAuth server...'); const loginResponse = await axios.post( 'http://localhost:3000/oauth/login', new URLSearchParams({ username, password, state: 'test-state', redirect_uri: 'http://localhost:3000/callback' }), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, maxRedirects: 0, validateStatus: (status) => status === 302 || status === 200 } ); if (loginResponse.status === 302 || loginResponse.status === 200) { console.log('✅ OAuth login successful!'); if (loginResponse.headers.location) { console.log('Redirect location:', loginResponse.headers.location); } } else { console.log('❌ OAuth login failed with status:', loginResponse.status); } } } catch (error) { console.log('❌ OAuth server test failed:', error.message); if (error.code === 'ECONNREFUSED') { console.log('⚠️ OAuth server is not running on localhost:3000'); console.log(' Please ensure the HTTPS server is running: npm run start:https'); } } // Test 3: Compare with user's credentials console.log('\n3️⃣ Testing user\'s credentials for comparison:'); const userCreds = { username: 'david+saola@umbrellacost.com', password: 'Dsamsung1!' }; try { const response = await axios.post( 'https://api.umbrellacost.io/api/v1/authenticate', userCreds, { headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' } } ); console.log('✅ User credentials work with direct API!'); } catch (error) { console.log('❌ User credentials failed:', error.response?.status, error.response?.statusText); } console.log('\n' + '=' .repeat(60)); console.log('📋 Summary:'); console.log('The test credentials from .env should work if they are valid.'); console.log('Compare this with the user\'s credentials to identify the issue.'); } // Run the test testOAuthWithEnvCreds().catch(err => { console.error('Unexpected error:', err); process.exit(1); });

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/daviddraiumbrella/invoice-monitoring'

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