Skip to content

Commit 77c1eaf

Browse files
Fixes "Missing credentials issue" (#31)
* Fix login issue: URL encode username and password in `get_basic_auth_token` to handle special characters * Added patch for the URL encoding in `get_basic_auth_token` * Added `encode_basic_auth.patch` to `generate.sh`
1 parent 65295e4 commit 77c1eaf

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

generate.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ patch ./vrchatapi/rest.py < ./patches/error_2fa_verify_readable.patch
3838
patch ./vrchatapi/configuration.py < ./patches/safe_param_symbols.patch
3939

4040
# Boolean to lower str conversion for query parameters
41-
patch ./vrchatapi/api_client.py < ./patches/query_param_bool.patch
41+
patch ./vrchatapi/api_client.py < ./patches/query_param_bool.patch
42+
43+
# Add URL encoding to basic auth parameters
44+
patch ./vrchatapi/configuration.py < ./patches/encode_basic_auth.patch

patches/encode_basic_auth.patch

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
diff --git a/vrchatapi/configuration.py b/vrchatapi/configuration.py
2+
index c0481ac4..45724ff1 100644
3+
--- a/vrchatapi/configuration.py
4+
+++ b/vrchatapi/configuration.py
5+
@@ -17,6 +17,7 @@ import logging
6+
import multiprocessing
7+
import sys
8+
import urllib3
9+
+import urllib.parse
10+
11+
import six
12+
from six.moves import http_client as httplib
13+
@@ -396,8 +397,13 @@ conf = vrchatapi.Configuration(
14+
password = ""
15+
if self.password is not None:
16+
password = self.password
17+
+
18+
+ #URL encoding username/password to avoid issues with special characters
19+
+ encoded_username = urllib.parse.quote(username)
20+
+ encoded_password = urllib.parse.quote(password)
21+
+
22+
return urllib3.util.make_headers(
23+
- basic_auth=username + ':' + password
24+
+ basic_auth=encoded_username + ':' + encoded_password
25+
).get('authorization')
26+
27+
def auth_settings(self):

vrchatapi/configuration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import multiprocessing
1818
import sys
1919
import urllib3
20+
import urllib.parse
2021

2122
import six
2223
from six.moves import http_client as httplib
@@ -396,8 +397,13 @@ def get_basic_auth_token(self):
396397
password = ""
397398
if self.password is not None:
398399
password = self.password
400+
401+
#URL encoding username/password to avoid issues with special characters
402+
encoded_username = urllib.parse.quote(username)
403+
encoded_password = urllib.parse.quote(password)
404+
399405
return urllib3.util.make_headers(
400-
basic_auth=username + ':' + password
406+
basic_auth=encoded_username + ':' + encoded_password
401407
).get('authorization')
402408

403409
def auth_settings(self):

0 commit comments

Comments
 (0)