Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 一旦我在Google Directory API中做了更改,如何更新用户电子邮件地址?_Python_List_Api_Google Api_Google Directory Api - Fatal编程技术网

Python 一旦我在Google Directory API中做了更改,如何更新用户电子邮件地址?

Python 一旦我在Google Directory API中做了更改,如何更新用户电子邮件地址?,python,list,api,google-api,google-directory-api,Python,List,Api,Google Api,Google Directory Api,我正在尝试使用Google Directory API更改组织的Google Admin目录中出现的所有用户的电子邮件地址。然而,我很难在做出更改后将更新提交到数据库 我已经打印出了所有的用户,并更改了他们的电子邮件地址,然后再次打印,看看更改是否奏效。然而,这只是在本地完成的,而我正在尝试将更新应用于实际用户帐户。因此,一旦我更改了电子邮件地址,我如何使用API进行实际更新?发布的代码来自GooglePython快速入门,只是做了一点小改动 # Call the Admin SDK Direc

我正在尝试使用Google Directory API更改组织的Google Admin目录中出现的所有用户的电子邮件地址。然而,我很难在做出更改后将更新提交到数据库

我已经打印出了所有的用户,并更改了他们的电子邮件地址,然后再次打印,看看更改是否奏效。然而,这只是在本地完成的,而我正在尝试将更新应用于实际用户帐户。因此,一旦我更改了电子邮件地址,我如何使用API进行实际更新?发布的代码来自GooglePython快速入门,只是做了一点小改动

# Call the Admin SDK Directory API
print('Getting the first 10 users in the domain')
results = service.users().list(customer='my_customer', maxResults=10,
                            orderBy='email').execute()
users = results.get('users', [])
user['email']['secondaryEmail'] = user['email']['customSchema']
#HOW DO I APPLY THIS CHANGE ON THE ACTUAL USER PROFILES NOW?

if not users:
    print('No users in the domain.')
else:
    print('Users:')
    for user in users:
        print(u'{0} ({1})'.format(user['primaryEmail'],
            user['name']['fullName']))
您可以使用重命名用户。在python中,它如下所示:

response = results = service.users().update(
    userKey='existing_email_address',
    body={
        'primaryEmail': 'newEmailAddress@domain.com'
    }
).execute()
print(response)