diff --git a/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs b/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs index 9e28ff6..c099bb5 100644 --- a/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs +++ b/src/Backend/DiunaBI.Infrastructure/Services/GoogleSheetsHelper.cs @@ -31,8 +31,25 @@ public class GoogleSheetsHelper var json = Environment.GetEnvironmentVariable("GOOGLE_SERVICE_ACCOUNT_JSON"); if (string.IsNullOrWhiteSpace(json)) 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"); - 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 } } \ No newline at end of file