google auth fix
All checks were successful
Build Docker Images / test (push) Successful in 1m13s
Build Docker Images / build-and-push (push) Successful in 1m40s

This commit is contained in:
2025-11-19 17:53:02 +01:00
parent cfb0cdc2f7
commit 62cf71eaa8

View File

@@ -31,8 +31,25 @@ public class GoogleSheetsHelper
var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON"); var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON");
if (string.IsNullOrWhiteSpace(json)) if (string.IsNullOrWhiteSpace(json))
throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set."); throw new InvalidOperationException("GOOGLE_SERVICE_ACCOUNT_JSON environment variable is not set.");
Console.WriteLine($"[GoogleSheetsHelper] Original JSON length: {json.Length}");
Console.WriteLine($"[GoogleSheetsHelper] First 200 chars: {json.Substring(0, Math.Min(200, json.Length))}");
// Replace literal \n with actual newlines
json = json.Replace("\\n", "\n"); json = json.Replace("\\n", "\n");
return GoogleCredential.FromJson(json).CreateScoped(Scopes);
Console.WriteLine($"[GoogleSheetsHelper] After replacement, first 200 chars: {json.Substring(0, Math.Min(200, json.Length))}");
try
{
return GoogleCredential.FromJson(json).CreateScoped(Scopes);
}
catch (Exception ex)
{
Console.WriteLine($"[GoogleSheetsHelper] ERROR parsing JSON: {ex.Message}");
Console.WriteLine($"[GoogleSheetsHelper] JSON being parsed: {json}");
throw;
}
#endif #endif
} }
} }