samuelvi/spreadsheet-translator-provider-onedriveauth
Composer 安装命令:
composer require samuelvi/spreadsheet-translator-provider-onedriveauth
包简介
Spreadsheet Translator - One Drive Provider with Authentication
README 文档
README
This package provides a provider for the Spreadsheet Translator project that fetches shared spreadsheet documents from Microsoft OneDrive using OAuth 2.0 authentication.
Features
- OAuth 2.0 authentication with Microsoft Live
- Supports both direct access token and interactive authentication flow
- Downloads Excel files from OneDrive via the Microsoft Live API
- Integrates seamlessly with the Spreadsheet Translator ecosystem
- Built with modern PHP 8.4 features
Installation
Install via Composer:
composer require samuelvi/spreadsheet-translator-provider-onedriveauth
Requirements
- PHP >= 8.4
- Guzzle HTTP client ^7.7
- Microsoft Azure application credentials (client ID and secret)
- OneDrive file ID of the spreadsheet to fetch
Usage
Configuration Options
The provider requires the following configuration options:
client_id: Your Microsoft application client IDclient_secret: Your Microsoft application client secretcallback_uri: OAuth redirect URI configured in your Microsoft appdocument_id: The OneDrive file ID to fetchaccess_token: (Optional) Pre-obtained access tokenprompt_for_access_token: (Optional) Enable interactive OAuth flowprompt_access_token_browser: (Optional) Browser preference for OAuth (e.g., 'chrome', 'firefox')scopes: (Optional) Comma-separated OAuth scopes (e.g., 'wl.offline_access,wl.skydrive_update')
Example Configuration
use Atico\SpreadsheetTranslator\Core\Configuration\Configuration; use Atico\SpreadsheetTranslator\Provider\OneDriveAuth\OneDriveAuthProvider; $config = new Configuration([ 'provider' => [ 'options' => [ 'client_id' => 'your-client-id', 'client_secret' => 'your-client-secret', 'callback_uri' => 'http://localhost/callback', 'document_id' => 'file.abc123.ABC123', 'access_token' => 'your-access-token', // or use prompt_for_access_token 'temp_local_source_file' => '/tmp/spreadsheet.xlsx', 'format' => 'xlsx' ] ] ]); $provider = new OneDriveAuthProvider($config); $resource = $provider->handleSourceResource();
Interactive Authentication
If you don't have an access token, enable interactive authentication:
$config = new Configuration([ 'provider' => [ 'options' => [ 'client_id' => 'your-client-id', 'client_secret' => 'your-client-secret', 'callback_uri' => 'http://localhost/callback', 'document_id' => 'file.abc123.ABC123', 'prompt_for_access_token' => true, 'prompt_access_token_browser' => 'chrome', 'scopes' => 'wl.offline_access,wl.skydrive_update', 'temp_local_source_file' => '/tmp/spreadsheet.xlsx', 'format' => 'xlsx' ] ] ]);
Development
Available Commands
The project includes a Makefile with common development tasks:
make help # Show all available commands make install # Install dependencies make update # Update dependencies make test # Run unit tests make test-coverage # Run tests with coverage report make phpstan # Run PHPStan static analysis make rector # Run Rector to upgrade code make rector-dry # Run Rector in dry-run mode (preview changes) make lint # Run all linting tools make fix # Auto-fix code with Rector make clean # Clean generated files make all # Install, lint, and test make ci # Run CI pipeline
Running Tests
# Run all tests make test # Run tests with coverage make test-coverage # Run specific test vendor/bin/phpunit tests/AuthTest.php
Code Quality
# Static analysis with PHPStan (level 8 + Mockery extension) make phpstan # Code refactoring (dry-run) make rector-dry # Apply code refactoring make rector
Architecture
This provider implements the ProviderInterface from the Core package and consists of:
- OneDriveAuthProvider: Main provider class that orchestrates the OAuth flow
- Auth: Handles OAuth 2.0 authentication with Microsoft Live
- Client: OneDrive API client for fetching file content
- CommandLineAccessTokenManager: Interactive CLI tool for obtaining OAuth tokens
- OneDriveAuthConfigurationManager: Configuration management
Related Packages
- Core Bundle - Base interfaces and utilities
- Symfony Bundle - Symfony integration
Contributing
We welcome contributions to this project, including pull requests and issues (and discussions on existing issues).
If you'd like to contribute code but aren't sure what, the issues list is a good place to start. If you're a first-time code contributor, you may find Github's guide to forking projects helpful.
All contributors (whether contributing code, involved in issue discussions, or involved in any other way) must abide by our code of conduct.
Development Setup
- Clone the repository
- Run
make installto install dependencies - Run
make testto ensure tests pass - Make your changes
- Run
make lintto check code quality - Run
make testto verify tests still pass - Submit a pull request
License
Spreadsheet Translator OneDrive Auth Provider is licensed under the MIT License. See the LICENSE file for full details.
samuelvi/spreadsheet-translator-provider-onedriveauth 适用场景与选型建议
samuelvi/spreadsheet-translator-provider-onedriveauth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 samuelvi/spreadsheet-translator-provider-onedriveauth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 samuelvi/spreadsheet-translator-provider-onedriveauth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-08