retitalia / google-client-api-bundle
此包实现了Google客户端API
此包的官方仓库似乎已不存在,因此该包已被冻结。
1.2.0
2018-12-21 13:20 UTC
Requires
- php: >=5.5.9
- google/apiclient: ^2.0
- retitalia/authentication-bundle: ^1.3
This package is not auto-updated.
Last update: 2020-02-14 18:39:36 UTC
README
此包实现了与Google的oauth2身份验证。
注意
该包正在积极开发中,目前不建议使用。
文档
此包已集成Guard,并验证用户是否已登录。如果没有登录,将通过oauth2调用Google进行身份验证。授权流程仍在开发中,并依赖于宿主应用程序。
安装
步骤1:下载包
打开命令行控制台,进入您的项目目录,并执行以下命令以下载此包的最新稳定版本
$ composer require retitalia/google-client-api-bundle
如果返回有关无法安装oauth2库的错误,这是由于bundle paragonie的问题。在这种情况下,请执行以下命令
Google_Service_Directory Google_Service_Directory_Alias Google_Service_Directory_Aliases Google_Service_Directory_AppAccessCollections Google_Service_Directory_Asp Google_Service_Directory_Asps Google_Service_Directory_Asps_Resource Google_Service_Directory_Building Google_Service_Directory_BuildingCoordinates Google_Service_Directory_Buildings Google_Service_Directory_CalendarResource Google_Service_Directory_CalendarResources Google_Service_Directory_Channel Google_Service_Directory_Channels_Resource Google_Service_Directory_ChromeOsDevice Google_Service_Directory_ChromeOsDeviceAction Google_Service_Directory_ChromeOsDeviceActiveTimeRanges Google_Service_Directory_ChromeOsDeviceDeviceFiles Google_Service_Directory_ChromeOsDeviceRecentUsers Google_Service_Directory_ChromeOsDevices Google_Service_Directory_Chromeosdevices_Resource Google_Service_Directory_ChromeOsDeviceTpmVersionInfo Google_Service_Directory_ChromeOsMoveDevicesToOu Google_Service_Directory_Customer Google_Service_Directory_CustomerPostalAddress Google_Service_Directory_Customers_Resource Google_Service_Directory_DomainAlias Google_Service_Directory_DomainAliases Google_Service_Directory_DomainAliases_Resource Google_Service_Directory_Domains Google_Service_Directory_Domains2 Google_Service_Directory_Domains_Resource Google_Service_Directory_Feature Google_Service_Directory_FeatureInstance Google_Service_Directory_FeatureRename Google_Service_Directory_Features Google_Service_Directory_Group Google_Service_Directory_Groups Google_Service_Directory_Groups_Resource Google_Service_Directory_GroupsAliases_Resource Google_Service_Directory_Member Google_Service_Directory_Members Google_Service_Directory_Members_Resource Google_Service_Directory_MembersHasMember Google_Service_Directory_MobileDevice Google_Service_Directory_MobileDeviceAction Google_Service_Directory_MobileDeviceApplications Google_Service_Directory_MobileDevices Google_Service_Directory_Mobiledevices_Resource Google_Service_Directory_Notification Google_Service_Directory_Notifications Google_Service_Directory_Notifications_Resource Google_Service_Directory_OrgUnit Google_Service_Directory_OrgUnits Google_Service_Directory_Orgunits_Resource Google_Service_Directory_Privilege Google_Service_Directory_Privileges Google_Service_Directory_Privileges_Resource Google_Service_Directory_ResolvedAppAccessSettings_Resource Google_Service_Directory_Resources_Resource Google_Service_Directory_ResourcesBuildings_Resource Google_Service_Directory_ResourcesCalendars_Resource Google_Service_Directory_ResourcesFeatures_Resource Google_Service_Directory_Role Google_Service_Directory_RoleAssignment Google_Service_Directory_RoleAssignments Google_Service_Directory_RoleAssignments_Resource Google_Service_Directory_RoleRolePrivileges Google_Service_Directory_Roles Google_Service_Directory_Roles_Resource Google_Service_Directory_Schema Google_Service_Directory_SchemaFieldSpec Google_Service_Directory_SchemaFieldSpecNumericIndexingSpec Google_Service_Directory_Schemas Google_Service_Directory_Schemas_Resource Google_Service_Directory_Token Google_Service_Directory_Tokens Google_Service_Directory_Tokens_Resource Google_Service_Directory_TrustedAppId Google_Service_Directory_TrustedApps Google_Service_Directory_User Google_Service_Directory_UserAbout Google_Service_Directory_UserAddress Google_Service_Directory_UserEmail Google_Service_Directory_UserExternalId Google_Service_Directory_UserGender Google_Service_Directory_UserIm Google_Service_Directory_UserKeyword Google_Service_Directory_UserLanguage Google_Service_Directory_UserLocation Google_Service_Directory_UserMakeAdmin Google_Service_Directory_UserName Google_Service_Directory_UserOrganization Google_Service_Directory_UserPhone Google_Service_Directory_UserPhoto Google_Service_Directory_UserPosixAccount Google_Service_Directory_UserRelation Google_Service_Directory_Users Google_Service_Directory_Users_Resource Google_Service_Directory_UsersAliases_Resource Google_Service_Directory_UsersPhotos_Resource Google_Service_Directory_UserSshPublicKey Google_Service_Directory_UserUndelete Google_Service_Directory_UserWebsite Google_Service_Directory_VerificationCode Google_Service_Directory_VerificationCodes Google_Service_Directory_VerificationCodes_Resource
然后重复包安装过程
阅读文档
https://developers.google.com/resources/api-libraries/documentation/admin/directory_v1/php/latest/
步骤2:启用包
然后,通过将其添加到项目app/AppKernel.php文件中注册的包列表中来启用该包
<?php //get All Users $users=$gSuite->getUsers(); //Set Email $gSuite->setEmail($email); //How to update Relations $gSuite->setRelationType('manager'); $gSuite->setRelationValue('Giangymongy@gmail.com'); $gSuite->setRelationCutomType(null); $gSuite->updateRelations(); //how to update Organization $gSuite->setOrganizationDepartment('Dipartimento degli stefanini logorroici'); $gSuite->setOrganizationPrimary(true); $gSuite->setOrganizationCustomType(null); $gSuite->setOrganizationName('Provola Nome'); $gSuite->updateOrganization(); // how to update personale information $gSuite->setFullName('Gianluca Mongelli'); $gSuite->setFamilyName('Mongelli'); $gSuite->setGivenName('Giangy'); $gSuite->setTelephonPrimary(true); #$gSuite->setTelephonType('work'); $gSuite->setTelephonNumber('3240537258'); $gSuite->updatePersonalInformation();
在parameters.yaml中设置作用域
scope_auth: [ 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/admin.directory.user.readonly', 'https://www.googleapis.com/auth/admin.directory.user.alias', 'https://www.googleapis.com/auth/admin.directory.group', 'https://www.googleapis.com/auth/admin.directory.group.readonly', 'https://www.googleapis.com/auth/admin.directory.group.member.readonly', 'https://www.googleapis.com/auth/admin.directory.orgunit', 'https://www.googleapis.com/auth/admin.directory.orgunit.readonly', 'https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.user.alias.readonly', 'https://www.googleapis.com/auth/admin.directory.userschema', 'https://www.googleapis.com/auth/admin.directory.domain']
参数的正确值可以从https://gitlab.com/retitalia/contenitore-bundle-comuni获取
许可证
此包采用MIT许可证。
用法
身份验证是自动的,通过oauth2调用Google SSO并执行流程。
授权基于特定的数据库。用户必须在正确的表中启用,并且必须具有指定应用程序的角色。
它通过application_id参数测试在parameters.yml中指定的应用程序。
但是还有一些其他有用的函数可以手动调用。