pirabyte/lexwareoffice-socialite 问题修复 & 功能扩展

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

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

pirabyte/lexwareoffice-socialite

最新稳定版本:v0.0.4

Composer 安装命令:

composer require pirabyte/lexwareoffice-socialite

包简介

Lexware Office OAuth2 Provider for Laravel Socialite

README 文档

README

composer require pirabyte/lexwareoffice-socialite

Add the following to your services.php,

'lexwareoffice' => [
    'url' => env('LEXWARE_OFFICE_URL', 'https://lexoffice-sandbox.grld.eu'),
    'api' => env('LEXWARE_OFFICE_API', 'https://api-sandbox.grld.eu'),
    'client_id' => env('LEXWARE_OFFICE_CLIENT_ID'),
    'client_secret' => env('LEXWARE_OFFICE_CLIENT_SECRET'),
    'redirect' => env('LEXWARE_OFFICE_REDIRECT_URL'),
],

In app/Providers/AppServiceProvider.php add the following listener to the SocialiteWasCalled event:

Event::listen(function (SocialiteWasCalled $event) {
    $event->extendSocialite('lexwareoffice', \Pirabyte\Socialite\LexwareOffice\Provider::class);
});

For Laravel < 11, add it to your EventServiceProvider.php.

Make sure you have the corresponding .env keys present:

  • LEXWARE_OFFICE_URL
  • LEXWARE_OFFICE_API
  • LEXWARE_OFFICE_CLIENT_ID
  • LEXWARE_OFFICE_CLIENT_SECRET
  • LEXWARE_OFFICE_REDIRECT_URL

How to use

In your controller create a new method

public function redirect()
{
    return Socialite::driver('lexwareoffice')->redirect();
}

This will redirect to lexware office to start the OAuth2.0 Flow.

Add another method to catch the response

public function callback(): \Illuminate\Http\RedirectResponse
{
    $connection = Socialite::driver('lexwareoffice')->user();
    $user = request()->user();

    LexwareOfficeClient::updateOrCreate([
        'user_id' => $user->id,
    ], [
        'access_token' => $connection->token,
        'refresh_token' => $connection->refreshToken,
        'expires_at' => Carbon::now()->addSeconds($connection->expiresIn),
    ]);

    return redirect()->route('dashboard');
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-06