google auth fix
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user