Skip to content
This repository was archived by the owner on Dec 20, 2021. It is now read-only.

Commit 20e7859

Browse files
authored
Merge pull request #20 from GhostJumper/master
added function for login with Base64 credentials
2 parents d5101bf + 8680656 commit 20e7859

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

vrcpy/client.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,27 @@ def login(self, username, password):
292292
self.me = objects.CurrentUser(self, resp["data"])
293293
self.loggedIn = True
294294

295+
def loginb64(self, b64):
296+
'''
297+
Used to initialize the client for use
298+
299+
b64, string
300+
Base64 Encoding of VRC account credentials
301+
302+
Returns void
303+
'''
304+
305+
if self.loggedIn:
306+
raise AlreadyLoggedInError("Client is already logged in")
307+
308+
resp = self.api.call("/auth/user", headers={"Authorization": "Basic "+b64}, no_auth=True)
309+
310+
self.api.set_auth(b64)
311+
self.api.session.cookies.set("auth", resp["response"].cookies["auth"])
312+
313+
self.me = objects.CurrentUser(self, resp["data"])
314+
self.loggedIn = True
315+
295316
def login2fa(self, username, password, code=None, verify=False):
296317
'''
297318
Used to initialize client for use (for accounts with 2FactorAuth)
@@ -650,6 +671,30 @@ async def login(self, username, password):
650671

651672
await self.me.cacheTask
652673

674+
async def loginb64(self, b64):
675+
'''
676+
Used to initialize the client for use
677+
678+
b64, string
679+
Base64 Encoding of VRC account credentials
680+
681+
Returns void
682+
'''
683+
684+
if self.loggedIn:
685+
raise AlreadyLoggedInError("Client is already logged in")
686+
687+
resp = await self.api.call("/auth/user", headers={"Authorization": "Basic "+b64}, no_auth=True)
688+
689+
self.api.openSession(b64)
690+
self.api.session.cookie_jar.update_cookies(
691+
[["auth", resp["response"].headers["Set-Cookie"].split(';')[0].split("=")[1]]])
692+
693+
self.me = aobjects.CurrentUser(self, resp["data"])
694+
self.loggedIn = True
695+
696+
await self.me.cacheTask
697+
653698
async def login2fa(self, username, password, code=None, verify=False):
654699
'''
655700
Used to initialize client for use (for accounts with 2FactorAuth)

0 commit comments

Comments
 (0)