krayin/krayin-google-integration

Krayin Google Integration

v1.0.0 2021-11-19 15:40 UTC

This package is auto-updated.

Last update: 2024-09-11 17:38:48 UTC


README

1. 简介

Krayin Google Integration。

它包含了许多强大的功能,可以让您的业务快速扩展。

  • 管理员用户可以连接到他们的Google账户。
  • 用户可以获取所选日历中的所有事件
  • 支持事件的双向同步
  • 支持实时事件同步
  • 用户可以直接从活动表单创建Google Meet链接

2. 要求

  • Krayin: v1.2.1 或更高版本。

3. 安装

  • 前往 Krayin 的根目录,并运行以下命令
composer require krayin/krayin-google-integration
  • 运行以下命令以完成设置
php artisan migrate
php artisan route:cache
php artisan vendor:publish

-> Press 0 and then press enter to publish all assets and configurations.

4. 配置

  • 前往 .env 文件并添加以下行
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI="${APP_URL}/google/oauth"
GOOGLE_WEBHOOK_URI="${APP_URL}/google/webhook"
  • 前往 config/services.php 文件并添加以下行
return [
    // ...
    
    'google' => [
        // Our Google API credentials.
        'client_id' => env('GOOGLE_CLIENT_ID'),
        'client_secret' => env('GOOGLE_CLIENT_SECRET'),
        
        // The URL to redirect to after the OAuth process.
        'redirect_uri' => env('GOOGLE_REDIRECT_URI'),
        
        // The URL that listens to Google webhook notifications (Part 3).
        'webhook_uri' => env('GOOGLE_WEBHOOK_URI'),
        
        // Let the user know what we will be using from his Google account.
        'scopes' => [
            // Getting access to the user's email.
            \Google_Service_Oauth2::USERINFO_EMAIL,
            
            // Managing the user's calendars and events.
            \Google_Service_Calendar::CALENDAR,
        ],
        
        // Enables automatic token refresh.
        'approval_prompt' => 'force',
        'access_type' => 'offline',
        
        // Enables incremental scopes (useful if in the future we need access to another type of data).
        'include_granted_scopes' => true,
    ],
];
  • 前往 app/Http/Middleware/VerifyCsrfToken.php 文件,并在 $except 数组下添加以下行
protected $except = [
    'google/webhook',
];
  • 前往 app/Console/Kernel.php 文件,并更新 schedule 函数为以下行
protected function schedule(Schedule $schedule)
{
    $schedule->job(new \Webkul\Google\Jobs\PeriodicSynchronizations())->everyFifteenMinutes();
    $schedule->job(new \Webkul\Google\Jobs\RefreshWebhookSynchronizations())->daily();
}

5. 清除缓存

php artisan cache:clear

php artisan config:cache

就这样,现在只需在指定的域名上运行项目即可。