diff --git a/generate.sh b/generate.sh index 5d0ebc2c..1db0021f 100755 --- a/generate.sh +++ b/generate.sh @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/patches/cookie_key_value.patch b/patches/cookie_key_value.patch new file mode 100644 index 00000000..56cf72fe --- /dev/null +++ b/patches/cookie_key_value.patch @@ -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': 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 @@ 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':