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

Commit cf7307a

Browse files
committed
verify param for Client and AClient
Verify ssl cert
1 parent a1e0b73 commit cf7307a

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

vrcpy/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ def handle_404():
242242
if resp["status"] != 200: raise GeneralError("Unhandled error occured: "+str(resp["data"]))
243243
if "requiresTwoFactorAuth" in resp["data"]: raise TwoFactorAuthNotSupportedError("2FA is not supported yet.")
244244

245-
def __init__(self):
246-
self.api = Call()
245+
def __init__(self, verify=True):
246+
self.api = Call(verify)
247247
self.loggedIn = False
248248
self.me = None
249249

@@ -448,10 +448,11 @@ async def wait_for_cache(self):
448448
while not self.cacheFull:
449449
await asyncio.sleep(1)
450450

451-
def __init__(self):
451+
def __init__(self, verify=True, log_to_console=False):
452452
super().__init__()
453453

454454
self.cacheFull = False
455-
self.api = ACall()
455+
self.log_to_console = log_to_console
456+
self.api = ACall(verify=verify)
456457
self.loggedIn = False
457458
self.me = None

vrcpy/request.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from vrcpy.errors import *
66

77
class ACall:
8-
def __init__(self, loop=asyncio.get_event_loop()):
8+
def __init__(self, loop=asyncio.get_event_loop(), verify=True):
9+
self.verify = verify
910
self.loop = loop
1011
self.session = None
1112
self.apiKey = None
@@ -31,7 +32,7 @@ async def call(self, path, method="GET", headers={}, params={}, json={}, no_auth
3132
return await self._call(path, method, headers, params, json)
3233

3334
if self.apiKey == None:
34-
async with self.session.get("https://api.vrchat.cloud/api/1/config") as resp:
35+
async with self.session.get("https://api.vrchat.cloud/api/1/config", verify_ssl=self.verify) as resp:
3536
assert resp.status == 200
3637
j = await resp.json()
3738

@@ -46,7 +47,7 @@ async def call(self, path, method="GET", headers={}, params={}, json={}, no_auth
4647
if type(params[param]) == bool: params[param] = str(params[param]).lower()
4748

4849
params["apiKey"] = self.apiKey
49-
async with self.session.request(method, path, params=params, headers=headers, json=json) as resp:
50+
async with self.session.request(method, path, params=params, headers=headers, json=json, verify_ssl=self.verify) as resp:
5051
if resp.status != 200:
5152
content = await resp.content.read()
5253

@@ -69,7 +70,7 @@ async def _call(self, path, method="GET", headers={}, params={}, json={}):
6970

7071
async with aiohttp.ClientSession(headers=h) as session:
7172
if self.apiKey == None:
72-
async with session.get("https://api.vrchat.cloud/api/1/config") as resp:
73+
async with session.get("https://api.vrchat.cloud/api/1/config", verify_ssl=self.verify) as resp:
7374
assert resp.status == 200
7475
j = await resp.json()
7576

@@ -84,7 +85,7 @@ async def _call(self, path, method="GET", headers={}, params={}, json={}):
8485
if type(params[param]) == bool: params[param] = str(params[param]).lower()
8586

8687
params["apiKey"] = self.apiKey
87-
async with session.request(method, path, params=params, headers=headers, json=json) as resp:
88+
async with session.request(method, path, params=params, headers=headers, json=json, verify_ssl=self.verify) as resp:
8889
if resp.status != 200:
8990
content = await resp.content.read()
9091

@@ -99,7 +100,8 @@ async def _call(self, path, method="GET", headers={}, params={}, json={}):
99100
return {"status": status, "data": json}
100101

101102
class Call:
102-
def __init__(self):
103+
def __init__(self, verify=True):
104+
self.verify = verify
103105
self.apiKey = None
104106
self.b64_auth = None
105107

@@ -123,7 +125,7 @@ def call(self, path, method="GET", headers={}, params={}, json={}, no_auth=False
123125
headers["Authorization"] = "Basic "+self.b64_auth
124126

125127
if self.apiKey == None:
126-
resp = self.session.get("https://api.vrchat.cloud/api/1/config")
128+
resp = self.session.get("https://api.vrchat.cloud/api/1/config", verify=self.verify)
127129
assert resp.status_code == 200
128130

129131
j = resp.json()
@@ -138,7 +140,7 @@ def call(self, path, method="GET", headers={}, params={}, json={}, no_auth=False
138140
if type(params[param]) == bool: params[param] = str(params[param]).lower()
139141

140142
params["apiKey"] = self.apiKey
141-
resp = self.session.request(method, path, headers=headers, params=params, json=json)
143+
resp = self.session.request(method, path, headers=headers, params=params, json=json, verify=self.verify)
142144

143145
if resp.status_code != 200:
144146
try: json = resp.json()
@@ -150,7 +152,7 @@ def call(self, path, method="GET", headers={}, params={}, json={}, no_auth=False
150152

151153
def _call(self, path, method="GET", headers={}, params={}, json={}):
152154
if self.apiKey == None:
153-
resp = requests.get("https://api.vrchat.cloud/api/1/config", headers=headers)
155+
resp = requests.get("https://api.vrchat.cloud/api/1/config", headers=headers, verify=self.verify)
154156
assert resp.status_code == 200
155157

156158
j = resp.json()
@@ -165,7 +167,7 @@ def _call(self, path, method="GET", headers={}, params={}, json={}):
165167
if type(params[param]) == bool: params[param] = str(params[param]).lower()
166168

167169
params["apiKey"] = self.apiKey
168-
resp = requests.request(method, path, headers=headers, params=params, data=json)
170+
resp = requests.request(method, path, headers=headers, params=params, data=json, verify=self.verify)
169171

170172
if resp.status_code != 200:
171173
try: json = resp.json()

0 commit comments

Comments
 (0)