帮助您从Laravel应用程序中管理GSuite账户[此包是在wyattcast44/gsuite包的基础上进一步开发的]

v1.1 2020-05-26 21:07 UTC

This package is auto-updated.

Last update: 2024-09-29 05:42:41 UTC


README

Latest Version on Packagist Total Downloads

这是一个围绕Google Admin SDK的包装器。它允许您在Laravel应用程序中管理您的G-Suite账户。如果您想查看示例,请参阅示例应用程序

警告:正在积极开发中,请自行承担风险。当准备测试时,将标记一个版本。

安装

您可以通过composer安装此包

composer require brickservers/gsuite

安装完成后,发布配置文件

php artisan vendor:publish

配置

  1. 设置您的账户为模拟
// .env
GOOGLE_SERVICE_ACCOUNT=email@domain.com
  1. 更新credentials_path,确保您已将凭证文件添加到您的.gitignore中。您可以从Google管理控制台下载此文件。
'credentials_path' => storage_path('credentials.json'),
  1. 设置您的域
// .env
GSUITE_DOMAIN=example.com
  1. 在配置文件中根据需要更改缓存设置

  2. 添加任何账户、别名或组,您想禁用删除能力。用于确保没有人可以删除您的服务账户。您仍然可以通过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');

缓存

默认情况下,accountsgroups被缓存。如果您选择不缓存结果,请求时间将会很长。当您删除、插入或更新资源时,缓存将自动刷新。您可以在任何时候刷新缓存,下面有示例。

// 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

更新日志

请参阅更新日志以获取有关最近更改的更多信息。

贡献

请参阅贡献指南以获取详细信息。

安全性

如果您发现任何安全问题,请通过wyatt.castaneda@gmail.com发送电子邮件,而不是使用问题跟踪器。

鸣谢

许可协议

MIT许可协议(MIT)。有关更多信息,请参阅许可文件

Laravel包模板

此包是用Laravel包模板生成的。