@@ -7,39 +7,38 @@ const prompt = (query) => new Promise((resolve) => rl.question(query, resolve));
77
88const configuration = new vrchat . Configuration ( {
99 username : "username" ,
10- password : "password"
10+ password : "password" ,
11+ baseOptions : {
12+ headers : { "User-Agent" : "ExampleProgram/0.0.1 my@email.com" }
13+ }
1114} ) ;
1215
13- const options = { headers : { "User-Agent" : "ExampleProgram/0.0.1 my@email.com" } } ;
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 ) ;
1719
18- AuthenticationApi . getCurrentUser ( options ) . then ( async resp => {
19- var currentUser = resp . data ;
20+ async function main ( ) {
21+ var currentUser = ( await authenticationApi . getCurrentUser ( ) ) . data ;
2022
2123 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 ;
2426 }
2527 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 ;
2830 }
2931
3032 console . log ( `Logged in as: ${ currentUser . displayName } ` ) ;
3133
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 ( ) ;
3442
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 } ` ) ;
3843
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- } ) ;
4544
0 commit comments