wyattcast44 / gsuite
帮助您从Laravel应用程序管理GSuite账户
Requires
- php: ^7.1
- google/apiclient: ^2.2
- illuminate/support: 5.8.*
- spatie/laravel-queueable-action: ^2.1
Requires (Dev)
- orchestra/testbench: 3.8.*
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2020-11-29 18:35:32 UTC
README
这是一个围绕Google Admin SDK的包装器。它允许您在Laravel应用程序中管理您的G-Suite账户。如果您想查看示例应用程序,请参阅示例应用程序。
警告:处于积极开发中,使用风险自担。当准备测试时,将标记版本。
更新:此包的开发已被暂停,我非常乐意继续构建此包,但我不再拥有GSuite账户,并且使用个人账户的成本太高。如果我能得到工作赞助的GSuite账户或某种形式的GSuite开发信用额度,我可能会重新开始。
安装
您可以通过composer安装此包
composer require wyattcast44/gsuite
安装完成后,发布配置文件
php artisan vendor:publish
配置
- 将您的账户设置为模拟
// .env GOOGLE_SERVICE_ACCOUNT=email@domain.com
- 更新
credentials_path
,确保您已将凭据文件添加到.gitignore
。您可以从Google管理控制台下载此文件
'credentials_path' => storage_path('credentials.json'),
- 设置您的域
// .env GSUITE_DOMAIN=example.com
-
在配置文件中按需更改缓存设置
-
添加任何您希望禁用删除能力的账户、别名或组。用于确保没有人可以删除您的服务账户。您仍然可以通过G-Suite管理员界面手动删除它们。
使用
GSuite账户管理
// Create a new G-Suite account GSuite::accounts()->create([ [ 'first_name' => 'John', 'last_name' => 'Doe', ], 'email' => 'john.doe@email.com', 'default_password' => 'password' ]); // Get a G-Suite account GSuite::accounts()->get('john.doe@example.com'); // Get a collection of all G-Suite accounts in your domain GSuite::accounts()->all(); // Delete a G-Suite account GSuite::accounts()->delete('john.doe@example.com'); // Suspend a G-Suite account GSuite::accounts()->suspend('john.doe@example.com'); // Add an alias to a G-Suite account GSuite::accounts()->alias('john.doe@example.com', 'support@example.com');
GSuite组管理
// Create a new G-Suite group GSuite::groups()->create('group.email@example.com', 'Group Name', 'Group description'); // Get a G-Suite group GSuite::groups()->get('group.email@example.com'); // Get a collection of all G-Suite groups in your domain GSuite::groups()->all(); // Delete a G-Suite group GSuite::groups()->delete('group.example@example.com'); // Add a member to a G-Suite group GSuite::groups()->addMember('group.email@example.com', 'john.doe@example.com');
缓存
默认情况下,accounts
和groups
会被缓存。如果您选择不缓存结果,请求时间将会很长。当您删除、插入或更新资源时,缓存将自动刷新。您可以在任何时候刷新缓存,下面有示例。
// Flush accounts and groups cache GSuite::flushCache(); // Flush only accounts cache GSuite::accounts()->flushCache(); // Flush only groups cache GSuite::groups()->flushCache(); // Via the CLI php artisan gsuite:flush-cache
其他资源
您可以使用GoogleServicesClient
类获取其他Google服务的API客户端,例如,假设您想管理您域的组织单元。
您可以这样获取组织单元的API客户端
$client = GSuiteServicesClient::getService('orgunit');
测试
composer test
更新日志
请参阅更新日志以获取更多关于最近更改的信息。
贡献
请参阅CONTRIBUTING以获取详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件 wyatt.castaneda@gmail.com 联系,而不是使用问题跟踪器。
鸣谢
许可协议
MIT 许可协议(MIT)。请参阅许可文件以获取更多信息。
Laravel 包模板
此包是使用Laravel 包模板生成的。