-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-zoom.js
More file actions
122 lines (99 loc) · 3.77 KB
/
Copy pathtest-zoom.js
File metadata and controls
122 lines (99 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Test script to validate Zoom API configuration
// Run with: node test-zoom.js
const fetch = require('node-fetch');
async function testZoomCredentials() {
console.log('🔍 Testing Zoom API Credentials...\n');
// Read environment variables
require('dotenv').config({ path: '.env.local' });
const accountId = process.env.ZOOM_ACCOUNT_ID;
const clientId = process.env.ZOOM_CLIENT_ID;
const clientSecret = process.env.ZOOM_CLIENT_SECRET;
console.log('Environment Variables:');
console.log('- ZOOM_ACCOUNT_ID:', accountId ? '✓ Set' : '❌ Missing');
console.log('- ZOOM_CLIENT_ID:', clientId ? '✓ Set' : '❌ Missing');
console.log('- ZOOM_CLIENT_SECRET:', clientSecret ? '✓ Set' : '❌ Missing');
console.log();
if (!accountId || !clientId || !clientSecret) {
console.log('❌ Missing required Zoom credentials');
return;
}
try {
// Test getting access token
console.log('📝 Step 1: Getting access token...');
const tokenUrl = 'https://zoom.us/oauth/token';
const credentials = Buffer.from(`${clientId}:${clientSecret}`).toString('base64');
const tokenResponse = await fetch(tokenUrl, {
method: 'POST',
headers: {
'Authorization': `Basic ${credentials}`,
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
grant_type: 'account_credentials',
account_id: accountId,
}),
});
if (!tokenResponse.ok) {
const error = await tokenResponse.text();
console.log('❌ Token request failed:', error);
return;
}
const tokenData = await tokenResponse.json();
console.log('✅ Access token obtained successfully');
// Test getting user info
console.log('📝 Step 2: Testing user info API...');
const userResponse = await fetch('https://api.zoom.us/v2/users/me', {
headers: {
'Authorization': `Bearer ${tokenData.access_token}`,
'Content-Type': 'application/json',
},
});
if (!userResponse.ok) {
const error = await userResponse.text();
console.log('❌ User API request failed:', error);
return;
}
const userData = await userResponse.json();
console.log('✅ User API test successful');
console.log('📋 User Info:');
console.log(`- Email: ${userData.email}`);
console.log(`- Name: ${userData.first_name} ${userData.last_name}`);
console.log(`- Type: ${userData.type}`);
console.log();
// Test creating a test meeting
console.log('📝 Step 3: Testing meeting creation...');
const meetingData = {
topic: 'Test Meeting - Zoom Integration',
type: 1, // Instant meeting
settings: {
host_video: true,
participant_video: true,
waiting_room: true,
},
};
const meetingResponse = await fetch('https://api.zoom.us/v2/users/me/meetings', {
method: 'POST',
headers: {
'Authorization': `Bearer ${tokenData.access_token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(meetingData),
});
if (!meetingResponse.ok) {
const error = await meetingResponse.text();
console.log('❌ Meeting creation failed:', error);
return;
}
const meetingResult = await meetingResponse.json();
console.log('✅ Meeting creation test successful');
console.log('📋 Meeting Details:');
console.log(`- ID: ${meetingResult.id}`);
console.log(`- Topic: ${meetingResult.topic}`);
console.log(`- Join URL: ${meetingResult.join_url}`);
console.log();
console.log('🎉 All Zoom API tests passed! Your integration is working correctly.');
} catch (error) {
console.log('❌ Error during testing:', error.message);
}
}
testZoomCredentials();