Skip to main content
Glama
test-cognito-auth.cjs3.77 kB
#!/usr/bin/env node const https = require('https'); const axios = require('axios'); // Create axios instance that ignores SSL certificate errors const axiosInstance = axios.create({ httpsAgent: new https.Agent({ rejectUnauthorized: false }) }); async function testCognitoAuth() { const baseUrl = 'https://api.umbrellacost.io/api/v1'; console.log('Testing Cognito authentication fallback...\n'); // Test AllCloud MSP user try { console.log('1. Testing AllCloud (MSP) user:'); console.log(' Username: david+allcloud@umbrellacost.com'); const response = await axiosInstance.post(`${baseUrl}/users/signin`, { username: 'david+allcloud@umbrellacost.com', password: 'Dsamsung1!123' }); if (response.data && response.data.jwtToken) { console.log(' ✅ Cognito authentication successful!'); console.log(' Token received:', response.data.jwtToken.substring(0, 50) + '...'); // Parse JWT to get user info const tokenPayload = JSON.parse(Buffer.from(response.data.jwtToken.split('.')[1], 'base64').toString()); console.log(' User Key:', tokenPayload.username || tokenPayload.sub); // Get user accounts const accountsResponse = await axiosInstance.get(`${baseUrl}/users`, { headers: { 'Authorization': response.data.jwtToken } }); if (accountsResponse.data && accountsResponse.data.accounts) { console.log(' Available accounts:', accountsResponse.data.accounts.length); accountsResponse.data.accounts.slice(0, 5).forEach((acc, i) => { console.log(` ${i+1}. ${acc.accountName} (Key: ${acc.accountKey})`); }); } } } catch (error) { console.error(' ❌ Cognito auth failed:', error.response?.data?.message || error.message); } console.log('\n' + '-'.repeat(60) + '\n'); // Test SAOLA direct user try { console.log('2. Testing SAOLA (Direct) user:'); console.log(' Username: david+saola@umbrellacost.com'); const response = await axiosInstance.post(`${baseUrl}/users/signin`, { username: 'david+saola@umbrellacost.com', password: 'Dsamsung1!' }); if (response.data && response.data.jwtToken) { console.log(' ✅ Cognito authentication successful!'); console.log(' Token received:', response.data.jwtToken.substring(0, 50) + '...'); // Parse JWT to get user info const tokenPayload = JSON.parse(Buffer.from(response.data.jwtToken.split('.')[1], 'base64').toString()); console.log(' User Key:', tokenPayload.username || tokenPayload.sub); // Get user accounts const accountsResponse = await axiosInstance.get(`${baseUrl}/users`, { headers: { 'Authorization': response.data.jwtToken } }); if (accountsResponse.data && accountsResponse.data.accounts) { console.log(' Available accounts:', accountsResponse.data.accounts.length); accountsResponse.data.accounts.slice(0, 5).forEach((acc, i) => { console.log(` ${i+1}. ${acc.accountName} (Key: ${acc.accountKey})`); }); } } } catch (error) { console.error(' ❌ Cognito auth failed:', error.response?.data?.message || error.message); } } testCognitoAuth().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/daviddraiumbrella/invoice-monitoring'

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