atico / spreadsheet-translator-provider-googledriveauth
Spreadsheet Translator - Google Drive With Authentication Provider
Installs: 2 534
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/atico/spreadsheet-translator-provider-googledriveauth
Requires
- php: >=8.4
- google/apiclient: ^2.0
- guzzlehttp/guzzle: ^7.7
- guzzlehttp/promises: ^2.0
- phpoffice/phpspreadsheet: ^3.0
- samuelvi/spreadsheet-translator-core: ^8.0
Requires (Dev)
- phpunit/phpunit: ^11.0
- rector/rector: ^2.1
README
This package retrieves protected spreadsheet documents from Google Drive with authentication support.
Features
- ๐ OAuth2 authentication with Google Drive API
- ๐ Support for Google Sheets spreadsheets
- ๐ Automatic token refresh
- ๐ Multiple output formats (XLSX, Matrix)
- ๐งช Comprehensive test coverage
- ๐ PHP 8.4 ready with modern syntax
Requirements
- PHP >= 8.4
- Composer
- Google Cloud Platform account with Drive API enabled
Installation
composer require samuelvi/spreadsheet-translator-provider-googledriveauth
How to Create Google Drive Credentials
- Create a project at Google Cloud Console. You will need a Google account.
- Enable the Google Sheets API following the official guide
- Download the Client Configuration file (credentials.json) to a private folder
- First-time authentication: When running the application for the first time, a URL will be displayed. Open it in your browser, grant permissions, and paste the authorization code back into the terminal.
Detailed Setup Steps
- Log into your Google account
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Sheets API and Google Drive API
- Create OAuth 2.0 credentials (Desktop app type recommended)
- Download the credentials JSON file
- Set up the configuration with the path to your credentials file
Usage
use Atico\SpreadsheetTranslator\Core\Configuration\Configuration; use Atico\SpreadsheetTranslator\Provider\GoogleDriveAuth\GoogleDriveAuthProvider; $configuration = new Configuration([ 'application_name' => 'My Application', 'credentials_path' => '/path/to/credentials.json', 'client_secret_path' => '/path/to/token.json', 'source_resource' => 'https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/edit', 'format' => 'xlsx', 'temp_local_source_file' => '/tmp/output.xlsx' ]); $provider = new GoogleDriveAuthProvider($configuration); $resource = $provider->handleSourceResource();
Development
Quick Start
# Install dependencies make install # Run tests make test # Run Rector code quality checks make rector-dry # Run all CI checks make ci
Available Make Commands
make install- Install all dependenciesmake update- Update all dependenciesmake test- Run testsmake test-coverage- Run tests with coverage reportmake rector- Apply Rector refactoringmake rector-dry- Check Rector suggestions without applyingmake clean- Remove vendor and cache directoriesmake ci- Run all CI checks (rector + tests)
Testing
The project includes comprehensive unit tests. Run them using:
make test # Or with coverage make test-coverage
Code Quality
This project uses Rector for automated refactoring and code quality improvements:
# Check what would be changed make rector-dry # Apply changes make rector
Related Projects
- Spreadsheet Translator Core - Core library
- Spreadsheet Translator Symfony Bundle - Symfony integration
Contributing
We welcome contributions! Please feel free to submit pull requests or open issues for bugs and feature requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run tests and code quality checks (
make ci) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
All contributors must abide by our code of conduct.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Author
Samuel Vicent - samuelvicent@gmail.com