G-Suite活动API-权限更改

时间:2018-08-01 06:38:21

标签: python gsuite

我正在尝试获取Gdrive文件夹的权限更改列表。我设法从下面的行中获取活动列表:

results = service.activities().list(source='drive.google.com', drive_fileId='1Obvn4enDbmJc_-rDSdANRuBFfZyICSC8yEzbaYMlsP0').execute()

这是一个测试文件夹,其中包含两个文件:“ test.docx”和“ test.xls”。

我希望我的脚本返回测试文件夹下每个文件的所有权限更改。我开始编写以下脚本

results = service.activities().list(source='drive.google.com',
drive_fileId='1Obvn4enDbmJc_-rDSdANRuBFfZyICSC8yEzbaYMlsP0').execute()
activities = results.get('activities', [])
if not activities:
    print('No activity.')
else:
    print('Recent activity:')
    for activity in activities:
        event = activity['combinedEvent']
        user = event.get('user', None)
        target = event.get('target', None)
        event_permissions = event.get('permissionChanges', None)
        #addedPermissions =  event_permissions['addedPermissions']
        for event_permission in event_permissions or []:
            new_permission = event_permission.get('addedPermissions',[])
            for addedPermission in new_permission:
               print (addedPermission['user'])

但是抛出了该错误:

  

TypeError:“ NoneType”对象不可迭代

0 个答案:

没有答案