@@ -7,39 +7,38 @@ const prompt = (query) => new Promise((resolve) => rl.question(query, resolve));
7
7
8
8
const configuration = new vrchat . Configuration ( {
9
9
username : "username" ,
10
- password : "password"
10
+ password : "password" ,
11
+ baseOptions : {
12
+ headers :
{ "User-Agent" :
"ExampleProgram/0.0.1 [email protected] " }
13
+ }
11
14
} ) ;
12
15
13
- const options = { headers :
{ "User-Agent" :
"ExampleProgram/0.0.1 [email protected] " } } ;
14
- const AuthenticationApi = new vrchat . AuthenticationApi ( configuration ) ;
15
- const UsersApi = new vrchat . UsersApi ( configuration ) ;
16
- const SystemApi = new vrchat . SystemApi ( configuration ) ;
16
+ const authenticationApi = new vrchat . AuthenticationApi ( configuration ) ;
17
+ const usersApi = new vrchat . UsersApi ( configuration ) ;
18
+ const systemApi = new vrchat . SystemApi ( configuration ) ;
17
19
18
- AuthenticationApi . getCurrentUser ( options ) . then ( async resp => {
19
- var currentUser = resp . data ;
20
+ async function main ( ) {
21
+ var currentUser = ( await authenticationApi . getCurrentUser ( ) ) . data ;
20
22
21
23
if ( currentUser [ "requiresTwoFactorAuth" ] && currentUser [ "requiresTwoFactorAuth" ] [ 0 ] === "emailOtp" ) {
22
- await AuthenticationApi . verify2FAEmailCode ( { code : await prompt ( "email Code\n" ) } , options )
23
- currentUser = ( await AuthenticationApi . getCurrentUser ( options ) ) . data ;
24
+ await authenticationApi . verify2FAEmailCode ( { code : await prompt ( "email Code\n" ) } )
25
+ currentUser = ( await authenticationApi . getCurrentUser ( ) ) . data ;
24
26
}
25
27
if ( currentUser [ "requiresTwoFactorAuth" ] && currentUser [ "requiresTwoFactorAuth" ] [ 0 ] === "totp" ) {
26
- await AuthenticationApi . verify2FA ( { code : await prompt ( "2fa Code\n" ) } , options )
27
- currentUser = ( await AuthenticationApi . getCurrentUser ( options ) ) . data ;
28
+ await authenticationApi . verify2FA ( { code : await prompt ( "2fa Code\n" ) } )
29
+ currentUser = ( await authenticationApi . getCurrentUser ( ) ) . data ;
28
30
}
29
31
30
32
console . log ( `Logged in as: ${ currentUser . displayName } ` ) ;
31
33
32
- SystemApi . getCurrentOnlineUsers ( options ) . then ( resp => {
33
- console . log ( `Current Online Users: ${ resp . data } ` ) ;
34
+ const currentOnlineUsers = ( await systemApi . getCurrentOnlineUsers ( ) ) . data ;
35
+ console . log ( `Current Online Users: ${ resp . data } ` ) ;
36
+
37
+ const tupperUser = ( await usersApi . getUser ( "usr_c1644b5b-3ca4-45b4-97c6-a2a0de70d469" ) ) . data ;
38
+ console . log ( resp . data . displayName ) ;
39
+ }
40
+
41
+ main ( ) ;
34
42
35
- // Calling getCurrentUser on Authentication API logs you in if the user isn't already logged in.
36
- AuthenticationApi . getCurrentUser ( options ) . then ( resp => {
37
- console . log ( `Logged in as: ${ resp . data . displayName } ` ) ;
38
43
39
- UsersApi . getUser ( "usr_c1644b5b-3ca4-45b4-97c6-a2a0de70d469" , options ) . then ( resp => {
40
- console . log ( resp . data . displayName ) ; // Should print out "tupper"
41
- } ) ;
42
- } ) ;
43
- } ) ;
44
- } ) ;
45
44
0 commit comments