From 244e84778e0f0930cf49003a63ecdca28060ae89 Mon Sep 17 00:00:00 2001 From: JelleJurre <76777936+jellejurre@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:31:36 +0200 Subject: [PATCH] Add url encoding to username and password (#21) --- generate.sh | 3 +++ src/VRChat.API/Api/AuthenticationApi.cs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/generate.sh b/generate.sh index edd523d0..56151326 100755 --- a/generate.sh +++ b/generate.sh @@ -37,6 +37,9 @@ for file in $(find ./src/VRChat.API -name '*.cs'); do sed -i 's/new Cookie(cookie.Name, cookie.Value)/new Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain)/g' $file done +# Fix username and password encoding +sed -i 's/VRChat.API.Client.ClientUtils.Base64Encode(this.Configuration.Username + \":\" + this.Configuration.Password)/VRChat.API.Client.ClientUtils.Base64Encode(System.Web.HttpUtility.UrlEncode(this.Configuration.Username) + ":" + System.Web.HttpUtility.UrlEncode(this.Configuration.Password))/g' src/VRChat.API/Api/AuthenticationApi.cs + # Fix fields in csproj sed -i 's/OpenAPI Library/VRChat API Library for .NET/' src/VRChat.API/VRChat.API.csproj sed -i 's/A library generated from a OpenAPI doc/VRChat API Library for .NET/' src/VRChat.API/VRChat.API.csproj diff --git a/src/VRChat.API/Api/AuthenticationApi.cs b/src/VRChat.API/Api/AuthenticationApi.cs index a9f7f213..74e49e2d 100644 --- a/src/VRChat.API/Api/AuthenticationApi.cs +++ b/src/VRChat.API/Api/AuthenticationApi.cs @@ -925,7 +925,7 @@ public VRChat.API.Client.ApiResponse GetCurrentUserWithHttpInfo(int // http basic authentication required if (!string.IsNullOrEmpty(this.Configuration.Username) || !string.IsNullOrEmpty(this.Configuration.Password) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + VRChat.API.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password)); + localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + VRChat.API.Client.ClientUtils.Base64Encode(System.Web.HttpUtility.UrlEncode(this.Configuration.Username) + ":" + System.Web.HttpUtility.UrlEncode(this.Configuration.Password))); } // authentication (twoFactorAuthCookie) required // cookie parameter support @@ -1007,7 +1007,7 @@ public VRChat.API.Client.ApiResponse GetCurrentUserWithHttpInfo(int // http basic authentication required if (!string.IsNullOrEmpty(this.Configuration.Username) || !string.IsNullOrEmpty(this.Configuration.Password) && !localVarRequestOptions.HeaderParameters.ContainsKey("Authorization")) { - localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + VRChat.API.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password)); + localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + VRChat.API.Client.ClientUtils.Base64Encode(System.Web.HttpUtility.UrlEncode(this.Configuration.Username) + ":" + System.Web.HttpUtility.UrlEncode(this.Configuration.Password))); } // authentication (twoFactorAuthCookie) required // cookie parameter support