Google Admin¶
Overview¶
The GoogleAdmin class allows you to get information about groups and members in Google Admin.
In order to instantiate the class, you must pass Google service account credentials as a dictionary,
or store the credentials as a JSON string in the GOOGLE_APPLICATION_CREDENTIALS environment variable.
You must also provide an email address for
domain-wide delegation.
Quickstart¶
To instantiate the GoogleAdmin class, you can either pass the constructor a dict
containing your Google service account credentials or define the environment variable
GOOGLE_APPLICATION_CREDENTIALS to contain a JSON encoding of the dict.
from parsons import GoogleAdmin
admin = GoogleAdmin(None, 'fakeemail@fakedomain.com')
from parsons import GoogleAdmin
credential_filename = 'google_application_credentials.json'
credentials = json.load(open(credential_filename))
sheets = GoogleAdmin(credentials, 'fakeemail@fakedomain.com')
members = admin.get_all_group_members('group_key')
groups = admin.get_all_groups(domain='fakedomain.com')
API¶
- class parsons.google.google_admin.GoogleAdmin(app_creds=None, sub=None)[source]¶
A connector for Google Admin.
- Parameters:
app_creds – str A credentials json string or a path to a json file. Not required if
GOOGLE_APPLICATION_CREDENTIALSenv variable set.sub – str An email address that this service account will act on behalf of (via domain-wide delegation)
- Returns:
GoogleAdmin Class
- get_aliases(group_key, params=None)[source]¶
Get aliases for a group.
Google Admin API Documentation – groups.aliases/list
- Parameters:
group_key – str The Google group id
params – dict A dictionary of fields for the GET request
- Returns:
Table Class
- get_all_group_members(group_key, params=None)[source]¶
Get all members in a group.
Google Admin API Documentation – manage-group-members#get_all_members
- Parameters:
group_key – str The Google group id
params – dict A dictionary of fields for the GET request
- Returns:
Table Class
- get_all_groups(params=None)[source]¶
Get all groups in a domain or account.
Google Admin API Documentation – manage-groups#get_all_domain_groups
- Parameters:
params – dict A dictionary of fields for the GET request.
- Returns:
Table Class