-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use baseOptions * Refactor example and add cookie examples
- Loading branch information
1 parent
ef0fc2c
commit 2f31e8b
Showing
3 changed files
with
82 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const vrchat = require("vrchat"); | ||
|
||
const configuration = new vrchat.Configuration({ | ||
username: "username", | ||
password: "password", | ||
baseOptions: { | ||
headers: { | ||
"User-Agent": "ExampleProgram/0.0.1 [email protected]" | ||
"Cookie": "auth=[AUTH_COOKIE_HERE]; twoFactorAuth=[TWO_FACTOR_AUTH_COOKIE_HERE]}" | ||
} | ||
} | ||
}); | ||
|
||
const AuthenticationApi = new vrchat.AuthenticationApi(configuration); | ||
|
||
async function main() { | ||
const currentUser = (await AuthenticationApi.getCurrentUser()).data; | ||
console.log(`Logged in as: ${currentUser.displayName}`); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const vrchat = require("vrchat"); | ||
|
||
const readline = require("readline") | ||
import globalAxios from "axios" | ||
|
||
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 AuthenticationApi(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 store = globalAxios.defaults.jar.store.idx["api.vrchat.cloud"]["/"]; | ||
console.log(`auth=${store["auth"]["value"]}`) | ||
console.log(`twoFactorAuth=${store["twoFactorAuth"]["value"]}`) | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,39 +7,38 @@ const prompt = (query) => new Promise((resolve) => rl.question(query, resolve)); | |
|
||
const configuration = new vrchat.Configuration({ | ||
username: "username", | ||
password: "password" | ||
password: "password", | ||
baseOptions: { | ||
headers: { "User-Agent": "ExampleProgram/0.0.1 [email protected]"} | ||
} | ||
}); | ||
|
||
const options = { 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); | ||
const authenticationApi = new vrchat.AuthenticationApi(configuration); | ||
const usersApi = new vrchat.UsersApi(configuration); | ||
const systemApi = new vrchat.SystemApi(configuration); | ||
|
||
AuthenticationApi.getCurrentUser(options).then(async resp => { | ||
var currentUser = resp.data; | ||
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") }, options) | ||
currentUser = (await AuthenticationApi.getCurrentUser(options)).data; | ||
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") }, options) | ||
currentUser = (await AuthenticationApi.getCurrentUser(options)).data; | ||
await authenticationApi.verify2FA({ code: await prompt("2fa Code\n") }) | ||
currentUser = (await authenticationApi.getCurrentUser()).data; | ||
} | ||
|
||
console.log(`Logged in as: ${currentUser.displayName}`); | ||
|
||
SystemApi.getCurrentOnlineUsers(options).then(resp => { | ||
console.log(`Current Online Users: ${resp.data}`); | ||
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(); | ||
|
||
// Calling getCurrentUser on Authentication API logs you in if the user isn't already logged in. | ||
AuthenticationApi.getCurrentUser(options).then(resp => { | ||
console.log(`Logged in as: ${resp.data.displayName}`); | ||
|
||
UsersApi.getUser("usr_c1644b5b-3ca4-45b4-97c6-a2a0de70d469", options).then(resp => { | ||
console.log(resp.data.displayName); // Should print out "tupper" | ||
}); | ||
}); | ||
}); | ||
}); | ||
|