Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ patch ./vrchatapi/configuration.py < ./patches/safe_param_symbols.patch
patch ./vrchatapi/api_client.py < ./patches/query_param_bool.patch

# Add URL encoding to basic auth parameters
patch ./vrchatapi/configuration.py < ./patches/encode_basic_auth.patch
patch ./vrchatapi/configuration.py < ./patches/encode_basic_auth.patch

# Set API key cookie as key-value pair
patch ./vrchatapi/api_client.py < ./patches/cookie_key_value.patch
22 changes: 22 additions & 0 deletions patches/cookie_key_value.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/vrchatapi/api_client.py b/vrchatapi/api_client.py
index ded48c2a..2f20fdcb 100644
--- a/vrchatapi/api_client.py
+++ b/vrchatapi/api_client.py
@@ -580,7 +580,16 @@ class ApiClient(object):
:param auth_setting: auth settings for the endpoint
"""
if auth_setting['in'] == 'cookie':
- headers['Cookie'] = auth_setting['value']
+ if not 'Cookie' in headers:
+ headers['Cookie'] = ""
+ else:
+ headers['Cookie'] += "; "
+ # Account for cookie value containing spaces and special characters
+ cookie_value = str(auth_setting['value'])
+ if not re.match("^\".*\"$", cookie_value):
+ cookie_value = cookie_value.replace("\"", "\\\"")
+ cookie_value = f"\"{cookie_value}\""
+ headers['Cookie'] += f"{auth_setting['key']}={cookie_value}"
elif auth_setting['in'] == 'header':
headers[auth_setting['key']] = auth_setting['value']
elif auth_setting['in'] == 'query':
11 changes: 10 additions & 1 deletion vrchatapi/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,16 @@ def _apply_auth_params(self, headers, queries, auth_setting):
:param auth_setting: auth settings for the endpoint
"""
if auth_setting['in'] == 'cookie':
headers['Cookie'] = auth_setting['value']
if not 'Cookie' in headers:
headers['Cookie'] = ""
else:
headers['Cookie'] += "; "
# Account for cookie value containing spaces and special characters
cookie_value = str(auth_setting['value'])
if not re.match("^\".*\"$", cookie_value):
cookie_value = cookie_value.replace("\"", "\\\"")
cookie_value = f"\"{cookie_value}\""
headers['Cookie'] += f"{auth_setting['key']}={cookie_value}"
elif auth_setting['in'] == 'header':
headers[auth_setting['key']] = auth_setting['value']
elif auth_setting['in'] == 'query':
Expand Down