tomshaw/google-api
Laravel Google OAuth 2.0 service client with configurable token storage (DB or custom), published config, and migrations. Integrates google/apiclient-services and supports Composer cleanup to include only the Google APIs you need (e.g., Gmail, Calendar).
Pros:
composer.json, reducing bloat and improving performance.StorageAdapterInterface, enabling flexibility for different deployment scenarios (e.g., serverless, microservices).GoogleCalendar, GoogleGmail) provide intuitive, method-chained interfaces for common operations (e.g., createEvent(), sendEmail()), reducing boilerplate.consent, auto), offline access, and scope management align with Google’s OAuth guidelines and security requirements.Cons:
composer.json constraints (PHP 8.5+) may require a full-stack upgrade, but the changelog shows active maintenance for Laravel 13.composer.json extra field (google/apiclient-services) allows opting into only required services (e.g., Gmail, Calendar), reducing deployment size and complexity.GoogleApiAccessorInterface.google/apiclient, which is actively maintained but may introduce breaking changes. The package’s changelog shows version adjustments (e.g., 0.7.1), indicating vigilance is needed.deleteAccessToken method exists but may need custom logic for handling Google’s token revocation APIs or user logout flows.google/apiclient-services for Gmail).retry helper or a custom middleware).Authentication Scope:
https://www.googleapis.com/auth/calendar) already approved in the Google Cloud Console? Unapproved scopes will fail OAuth flows.Token Storage:
StorageAdapterInterface?Error Handling:
403 Forbidden, 429 Too Many Requests) be surfaced to users? The package lacks built-in error translation.Testing:
Mockery or VCR recordings)?Monitoring:
Security:
auth_config) be secured (e.g., environment variables, secrets manager)? The package doesn’t enforce encryption or access controls.Future-Proofing:
Prerequisites:
Installation:
composer require tomshaw/google-api
php artisan vendor:publish --provider="TomShaw\GoogleApi\Providers\GoogleApiServiceProvider" --tag=config
config/google-api.php with:
auth_config: Path to the downloaded JSON credentials file.service_scopes: Array of required scopes (e.g., ['https://www.googleapis.com/auth/calendar']).token_storage_adapter: Defaults to DatabaseTokenStorage; override for custom storage.Selective Service Loading:
composer.json to opt into only needed services:
"extra": {
"google/apiclient-services": ["Gmail", "Calendar"]
}
composer dump-autoload to clean up unused services.Database Migration (Optional):
DatabaseTokenStorage, run:
php artisan migrate
google_api_tokens table for storing OAuth tokens.Authentication Flow:
// Redirect user to Google for auth
route('google.auth', [GoogleAuthController
How can I help you explore Laravel packages today?