-
Notifications
You must be signed in to change notification settings - Fork 17
/
example.js
44 lines (31 loc) · 1.56 KB
/
example.js
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
const vrchat = require("vrchat");
const readline = require("readline")
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
const prompt = (query) => new Promise((resolve) => rl.question(query, resolve));
const configuration = new vrchat.Configuration({
username: "username",
password: "password",
baseOptions: {
headers: { "User-Agent": "ExampleProgram/0.0.1 [email protected]"}
}
});
const authenticationApi = new vrchat.AuthenticationApi(configuration);
const usersApi = new vrchat.UsersApi(configuration);
const systemApi = new vrchat.SystemApi(configuration);
async function main() {
var currentUser = (await authenticationApi.getCurrentUser()).data;
if (currentUser["requiresTwoFactorAuth"] && currentUser["requiresTwoFactorAuth"][0] === "emailOtp") {
await authenticationApi.verify2FAEmailCode({ code: await prompt("email Code\n") })
currentUser = (await authenticationApi.getCurrentUser()).data;
}
if (currentUser["requiresTwoFactorAuth"] && currentUser["requiresTwoFactorAuth"][0] === "totp") {
await authenticationApi.verify2FA({ code: await prompt("2fa Code\n") })
currentUser = (await authenticationApi.getCurrentUser()).data;
}
console.log(`Logged in as: ${currentUser.displayName}`);
const currentOnlineUsers = (await systemApi.getCurrentOnlineUsers()).data;
console.log(`Current Online Users: ${resp.data}`);
const tupperUser = (await usersApi.getUser("usr_c1644b5b-3ca4-45b4-97c6-a2a0de70d469")).data;
console.log(resp.data.displayName);
}
main();