{"id":23858970,"url":"https://github.com/coloredcow/laravel-gsuite","last_synced_at":"2025-03-17T16:12:02.676Z","repository":{"id":56956683,"uuid":"142300455","full_name":"ColoredCow/laravel-gsuite","owner":"ColoredCow","description":"A Laravel package to setup Google OAuth and GSuite Admin SDK.","archived":false,"fork":false,"pushed_at":"2025-02-16T10:22:27.000Z","size":20,"stargazers_count":18,"open_issues_count":4,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T23:12:24.704Z","etag":null,"topics":["google","google-api","gsuite","laravel"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ColoredCow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-25T13:00:14.000Z","updated_at":"2025-02-16T10:22:30.000Z","dependencies_parsed_at":"2025-01-03T03:31:18.677Z","dependency_job_id":null,"html_url":"https://github.com/ColoredCow/laravel-gsuite","commit_stats":{"total_commits":8,"total_committers":3,"mean_commits":"2.6666666666666665","dds":0.25,"last_synced_commit":"da8e09a5164288bde3d5ff426cd19604ed91dc76"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColoredCow%2Flaravel-gsuite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColoredCow%2Flaravel-gsuite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColoredCow%2Flaravel-gsuite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ColoredCow%2Flaravel-gsuite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ColoredCow","download_url":"https://codeload.github.com/ColoredCow/laravel-gsuite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066189,"owners_count":20392406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google","google-api","gsuite","laravel"],"created_at":"2025-01-03T03:28:57.507Z","updated_at":"2025-03-17T16:12:02.654Z","avatar_url":"https://github.com/ColoredCow.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel GSuite\nA Laravel package to setup Google OAuth and GSuite Admin SDK.\n\n## Installation\nYou can install the package using composer\n```\ncomposer require coloredcow/laravel-gsuite\n```\n\nPublish the configurations\n```\nphp artisan vendor:publish --provider=\"ColoredCow\\LaravelGSuite\\Providers\\GSuiteServiceProvider\" --tag=\"config\"\n```\n\n## Setting up Google Oauth\nUpdate your .env file with the Google OAuth 2.0 credentials\n```\nGOOGLE_CLIENT_ID=your_google_client_id\nGOOGLE_CLIENT_SECRET=your_google_client_secret\nGOOGLE_CLIENT_CALLBACK=your_google_callback_url\n```\n\n**NOTE:** If you wish to restrict users to your organization's domain, add to your .env\n```\nGOOGLE_CLIENT_HD=your_domain\n```\n\nInside your `app/Http/Controllers/Auth/LoginController.php`, use the package trait `GSuiteLogin`\n```php\n\u003c?php\n\nuse ColoredCow\\LaravelGSuite\\Traits\\GSuiteLogin;\n\nclass LoginController extends Controller\n{\n\n    use AuthenticatesUsers, GSuiteLogin;\n\n    // ...\n```\n\nThat's it! Go to `your_app_url/auth/google` and use your Google email to login.\n\n## Setting up GSuite Admin Service\nIn your `.env` file, add the following credentials:\n```\nGOOGLE_APPLICATION_CREDENTIALS=your_gsuite_service_account_crendentials\nGOOGLE_SERVICE_ACCOUNT_IMPERSONATE=your_gsuite_admin_email\n```\nTo know more about service account and steps to get one, visit [the official Google Documentation](https://developers.google.com/identity/protocols/OAuth2ServiceAccount).\n\n**NOTE:** Make sure you enable `Domain-wide Delegation` when creating the service account for your project.\n\nYou can now use various services provided by the package. For example, if you want to fetch a user details, you can use the `GSuiteUserService` facade.\n```php\nuse ColoredCow\\LaravelGSuite\\Facades\\GSuiteUserService;\n\n// ...\n\n$user = GSuiteUserService::fetch('jon@mycompany.com');\n\necho $user-\u003egetName(); // Jon Snow\necho $user-\u003egetJoinedOn(); // 2016-12-26 12:15:00\necho $user-\u003egetDesignation(); // Lord Commander\n```\n\n## Enabling multitenancy\nThere are some additional steps required in case your application supports multitenancy.\n\nSet multitenancy to **true** in your `config/gsuite.php`\n```php\n'multitenancy' =\u003e true,\n```\n\nThe default value for tenant connection is `tenant`. If you're using a different name for tenant connection, update `config/gsuite.php`\n```php\n'connections' =\u003e [\n    'tenant' =\u003e 'tenant_connection',\n]\n```\n\nSince you'll have multiple tenants, and you may need different GSuite API credentials for each of them, the package will create a table in each tenant database. This table will store the required gsuite credentials.\n\nPublish the tenant specific migrations using the following command. This will publish the migrations into `database/migrations/tenant` directory.\n```\nphp artisan vendor:publish --provider=\"ColoredCow\\LaravelGSuite\\Providers\\GSuiteServiceProvider\" --tag=\"multitenancy\"\n```\nNow, create your tenant databases.\n\n**NOTE:** If you already have existing tenants, you may need to recreate those tenant databases. You may lose some data if not done carefully.\n\nIn every tenant database, you need to define the application credentials and service account impersonate user. You can add a seeder to your multitenancy implementation so that it runs everytime a new tenant database is created.\n\nYour `gsuite_configurations` table should look this\n\n|id|key|value|created_at|updated_at|\n|-|-|-|-|-|\n|1|application_credentials|full_path_to_credentials.json|2018-06-06 16:00:00|2018-06-06 16:00:00|\n|2|service_account_impersonate|`admin@mycompany.com`|2018-06-06 16:00:00|2018-06-06 16:00:00|\n\n### More multitenancy configurations\nIf you prefer to have a different name for the `gsuite_configurations` table, update `config/gsuite.php`\n```php\n'tables' =\u003e [\n    'tenant' =\u003e [\n        'gsuite-configurations' =\u003e 'your_gsuite_table_name',\n    ]\n]\n```\n\nIf you prefer to override the package's `GSuiteConfiguration` model, create a custom model that must implement the `ColoredCow\\LaravelGSuite\\Contracts\\Tenant\\GSuiteConfiguration` contract. Then, update your `config/gsuite.php` and replace the default model with the new model.\n```php\n'models' =\u003e [\n    'tenant' =\u003e [\n        'gsuite-configuration' =\u003e App\\YourModelName::class\n    ]\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoloredcow%2Flaravel-gsuite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoloredcow%2Flaravel-gsuite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoloredcow%2Flaravel-gsuite/lists"}