You must get the google api PHP code here: https://github.com/google/google-api-php-client (For composer "google/apiclient": "~1.1"
.)
My example code is from Laravel 5.1, but it should be easily adaptable to any framework/code base.
This roughly explains what to do for a generic admin account: https://developers.google.com/admin-sdk/directory/v1/guides/delegation
So you would
- Create the user
- Log in as the user
- Go to: https://console.developers.google.com/
- Create a new app
- Enable the Admin SDK under APIs & Auth -> APIs
- Go to APIs & Auth -> Credentials click Add Credentials -> Service Account
- Key Type is JSON (Download and save the key)
Then go back into the Domain Admin Console
- Go to your Google Apps domain’s Admin console.
- Select Security from the list of controls. If you don't see Security listed, select More controls from the gray bar at the bottom of the page, then select Security from the list of controls.
- Select Advanced settings from the list of options.
- Select Manage third party OAuth Client access in the Authentication section.
- In the Client name field enter the service account's Client ID.
- In the One or More API Scopes field enter the list of scopes that your application should be granted access to (see image below). For example if you need domain-wide access to Users and Groups and Group Membership enter: https://www.googleapis.com/auth/admin.directory.user, https://www.googleapis.com/auth/admin.directory.group,https://www.googleapis.com/auth/admin.directory.group.member (I think we plan to use all 3 of these permissions eventually so people can use MySBTS to create google groups for their department or other needs. Troy started this but never integrated Google.)
- Click the Authorize button.
Once all that is done, I need the JSON file and the email address of the generic account.