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

Commit 0c9ef10

Browse files
committed
Reimplement login_auth_token
1 parent 6bba10c commit 0c9ef10

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

vrcpy/client.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,31 @@ async def login(self, username, password, mfa=None):
348348

349349
await self._pre_loop()
350350

351-
async def login_auth_token(self):
352-
pass
351+
async def login_auth_token(self, token: str):
352+
'''
353+
Used to login as a VRC user using an existing auth token
354+
token, str
355+
Authtoken to login with
356+
'''
357+
358+
logging.debug("Doing logon with pre-existing auth token")
359+
360+
# Create a session and get api_key
361+
await self.fetch_system_time()
362+
self.request.session.cookie_jar.update_cookies([["auth", token]])
363+
364+
try:
365+
resp = await self.request.get("/auth")
366+
except ClientErrors.MissingCredentials:
367+
raise ClientErrors.InvalidAuthToken(
368+
"Passed auth token is not valid")
369+
370+
if not resp["data"]["ok"]:
371+
raise ClientErrors.InvalidAuthToken(
372+
"Passed auth token is not valid")
373+
374+
await self.fetch_me()
375+
await self._pre_loop()
353376

354377
async def verify_mfa(self, mfa: str):
355378
'''

0 commit comments

Comments
 (0)