samuelvi/spreadsheet-translator-provider-onedriveauth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

samuelvi/spreadsheet-translator-provider-onedriveauth

Composer 安装命令:

composer require samuelvi/spreadsheet-translator-provider-onedriveauth

包简介

Spreadsheet Translator - One Drive Provider with Authentication

README 文档

README

PHP Version License

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 ID
  • client_secret: Your Microsoft application client secret
  • callback_uri: OAuth redirect URI configured in your Microsoft app
  • document_id: The OneDrive file ID to fetch
  • access_token: (Optional) Pre-obtained access token
  • prompt_for_access_token: (Optional) Enable interactive OAuth flow
  • prompt_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

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

  1. Clone the repository
  2. Run make install to install dependencies
  3. Run make test to ensure tests pass
  4. Make your changes
  5. Run make lint to check code quality
  6. Run make test to verify tests still pass
  7. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 samuelvi/spreadsheet-translator-provider-onedriveauth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 31
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-08