Code Snippet Server
by ngeojiajun
Verified
- src
- services
import { GoogleAuthService } from "./google-auth-service.js";
import { google } from "googleapis";
export abstract class GoogleBaseService {
protected auth = GoogleAuthService.getInstance();
constructor() {
// Ensure auth is initialized before using any Google service
this.initializeAuth().catch((error) => {
console.error("Failed to initialize Google auth:", error);
throw error;
});
}
private async initializeAuth(): Promise<void> {
await this.auth.initialize();
await this.auth.authenticate();
}
protected async waitForInit(): Promise<void> {
await this.initializeAuth();
}
}