From c512389db8904ea4b4fa1b362e24e455fe0ad209 Mon Sep 17 00:00:00 2001 From: kis1yi <35934681+kis1yi@users.noreply.github.com> Date: Sun, 7 Jun 2026 22:24:36 +0200 Subject: [PATCH 1/3] Improved first-time login algorithm on rusro --- .../Components/RuSroAuthService.cs | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/Plugins/RSBot.General/Components/RuSroAuthService.cs b/Plugins/RSBot.General/Components/RuSroAuthService.cs index 841dbe52..cfd21141 100644 --- a/Plugins/RSBot.General/Components/RuSroAuthService.cs +++ b/Plugins/RSBot.General/Components/RuSroAuthService.cs @@ -38,8 +38,6 @@ public static async Task Auth() return false; } - Log.Debug(selectedAccount?.Username); - string username = selectedAccount.Username; string password = selectedAccount.Password; @@ -119,11 +117,16 @@ public static async Task TokenResponse(string username, string password) var parameters = new List>(); string refreshToken = GlobalConfig.Get("RSBot.RuSro.refreshToken"); string accessToken = GlobalConfig.Get("RSBot.RuSro.accessToken"); + string sessionId = GlobalConfig.Get("RSBot.RuSro.sessionId"); + string endpoint = "https://launcherbff.ru.4game.com/connect/token"; + + HttpContent tokenRequestContent = null; + if ( !string.IsNullOrEmpty(refreshToken) && !string.IsNullOrEmpty(accessToken) && ExtractUsernameEmailFromToken(accessToken).Contains(username.ToLower()) - ) + ) { parameters.Add(new KeyValuePair("grant_type", "refresh_token")); parameters.Add(new KeyValuePair("refresh_token", refreshToken)); @@ -135,11 +138,21 @@ public static async Task TokenResponse(string username, string password) parameters.Add(new KeyValuePair("secure", "true")); parameters.Add(new KeyValuePair("grant_type", "password")); } - var tokenRequestContent = new FormUrlEncodedContent(parameters); + tokenRequestContent = new FormUrlEncodedContent(parameters); var hwid = GlobalConfig.Get("RSBot.RuSro.hwid", randomHwid); var launcherId = GlobalConfig.Get("RSBot.RuSro.launcherid", randomLauncherId); + if (!string.IsNullOrEmpty(sessionId) + && string.IsNullOrEmpty(refreshToken) + && string.IsNullOrEmpty(accessToken) + ) + { + //Instead of POST application/json with sessionId to https://launcherbff.ru.4game.com/api/guard/accesscodes/resend + hwid = randomHwid; + launcherId = randomLauncherId; + } + GlobalConfig.Set("RSBot.RuSro.hwid", hwid); GlobalConfig.Set("RSBot.RuSro.launcherid", launcherId); GlobalConfig.Save(); @@ -147,15 +160,17 @@ public static async Task TokenResponse(string username, string password) Log.Debug($"HWID: {hwid}"); Log.Debug($"Launcher ID: {launcherId}"); + client.DefaultRequestHeaders.Remove("Hardware-Id"); + client.DefaultRequestHeaders.Remove("Launcher-Id"); client.DefaultRequestHeaders.Add("Hardware-Id", hwid); client.DefaultRequestHeaders.Add("Launcher-Id", launcherId); - var tokenResponse = await client.PostAsync( - "https://launcherbff.ru.4game.com/connect/token", - tokenRequestContent - ); - var tokenResponseContent = await tokenResponse.Content.ReadAsStringAsync(); - return tokenResponseContent; + using (tokenRequestContent) + { + var tokenResponse = await client.PostAsync(endpoint, tokenRequestContent); + var tokenResponseContent = await tokenResponse.Content.ReadAsStringAsync(); + return tokenResponseContent; + } } private static async Task GetAccessTokenAsync(string username, string password) From 1231e51541e9f168e1819459a4fb55e738f67a89 Mon Sep 17 00:00:00 2001 From: kis1yi <35934681+kis1yi@users.noreply.github.com> Date: Sun, 7 Jun 2026 22:31:36 +0200 Subject: [PATCH 2/3] removed the tab --- Plugins/RSBot.General/Components/RuSroAuthService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/RSBot.General/Components/RuSroAuthService.cs b/Plugins/RSBot.General/Components/RuSroAuthService.cs index cfd21141..9e429ee3 100644 --- a/Plugins/RSBot.General/Components/RuSroAuthService.cs +++ b/Plugins/RSBot.General/Components/RuSroAuthService.cs @@ -126,7 +126,7 @@ public static async Task TokenResponse(string username, string password) !string.IsNullOrEmpty(refreshToken) && !string.IsNullOrEmpty(accessToken) && ExtractUsernameEmailFromToken(accessToken).Contains(username.ToLower()) - ) + ) { parameters.Add(new KeyValuePair("grant_type", "refresh_token")); parameters.Add(new KeyValuePair("refresh_token", refreshToken)); From fa5a2c8723b99f45435d63b4470d134701761d11 Mon Sep 17 00:00:00 2001 From: kis1yi <35934681+kis1yi@users.noreply.github.com> Date: Sun, 7 Jun 2026 22:48:06 +0200 Subject: [PATCH 3/3] Line breaks removed --- Plugins/RSBot.General/Components/RuSroAuthService.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Plugins/RSBot.General/Components/RuSroAuthService.cs b/Plugins/RSBot.General/Components/RuSroAuthService.cs index 9e429ee3..2c163501 100644 --- a/Plugins/RSBot.General/Components/RuSroAuthService.cs +++ b/Plugins/RSBot.General/Components/RuSroAuthService.cs @@ -143,10 +143,7 @@ public static async Task TokenResponse(string username, string password) var hwid = GlobalConfig.Get("RSBot.RuSro.hwid", randomHwid); var launcherId = GlobalConfig.Get("RSBot.RuSro.launcherid", randomLauncherId); - if (!string.IsNullOrEmpty(sessionId) - && string.IsNullOrEmpty(refreshToken) - && string.IsNullOrEmpty(accessToken) - ) + if (!string.IsNullOrEmpty(sessionId) && string.IsNullOrEmpty(refreshToken) && string.IsNullOrEmpty(accessToken)) { //Instead of POST application/json with sessionId to https://launcherbff.ru.4game.com/api/guard/accesscodes/resend hwid = randomHwid;