
Mobiledevice_list = get_mobiledevice_list(admin, customerId)Īction_mobiledevice(admin, customerId, resourceId, action) Results = admin.mobiledevices().action(customerId=customerId, resourceId=resourceId, body=body).execute() Print(u')'.format(mobiledevice, mobiledevice))ĭef action_mobiledevice(admin, customerId, resourceId, actionName): # actionName: "approve", "block",etc Print('mobile devices name and resourceId') Mobiledevices = results.get('mobiledevices', ) Results = admin.mobiledevices().list(customerId=customerId).execute() # admin = ('admin', 'directory_v1', credentials=credentials)Īdmin = ('admin', 'directory_v1', credentials=delegated_credentials)ĭef get_mobiledevice_list(admin, customerId): # Set CustomerID, ResourceID, and EMAIL_ACCOUNT for your GSuite account before usingįrom google.oauth2 import service_accountĬredentials = service_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)ĭelegated_credentials = credentials.with_subject(EMAIL_ACCOUNT) # Takes an action to set a device into approve or deny state # Google Cloud Function meant to respond to a webhook Once you have all that, you can upload mobiledevice.py in your Google Cloud Console. To setup a GSuite Account for Google Functions and grab the ResourceID (or JWT), see:.

Before using the function you’ll want to set CustomerID, ResourceID, and EMAIL_ACCOUNT for your GSuite account before using.

This function takes an action to set a device into ‘approve’ or ‘deny’ as a state within Google Directory. This allows you to control access based on a variety of factors.īelow, you’ll find a Google Cloud Function that is meant to respond to a webhook. The Google Directory integration with GSuite allows you to manage which devices have access to GSuite.
