需要授权
请求
HTTP 请求
PUT https://www.googleapis.com/tagmanager/v1/accounts/accountId/permissions/permissionId
参数
参数名称 | 值 | 说明 |
---|---|---|
路径参数 | ||
accountId |
string |
GTM 帐号 ID。 |
permissionId |
string |
GTM 用户 ID。 |
授权
此请求需要获得下列范围的授权(详细了解身份验证和授权)。
范围 |
---|
https://www.googleapis.com/auth/tagmanager.manage.users |
请求正文
在请求正文中,提供具有以下属性的 Permissions 资源:
属性名称 | 值 | 说明 | 备注 |
---|---|---|---|
可选属性 | |||
accountAccess |
nested object |
GTM 帐号访问权限。 | 可写入 |
accountAccess.permission[] |
list |
帐号权限列表。有效的帐号权限包括 read 和 manage 。 |
可写入 |
containerAccess[] |
list |
GTM 容器访问权限。 | 可写入 |
containerAccess[].containerId |
string |
GTM 容器 ID。 | 可写入 |
containerAccess[].permission[] |
list |
容器权限列表。有效的容器权限包括:read, edit, delete, publish 。 |
可写入 |
响应
如果成功,此方法将在响应正文中返回 Permissions 资源。
示例
备注:此方法的代码示例并未列出所有受支持的编程语言(请参阅客户端库页面,查看受支持的语言列表)。
Java
使用 Java 客户端库。
/* * Note: This code assumes you have an authorized tagmanager service object. */ /* * This request updates a user's permissions to access a GTM account. */ // Construct the container access object. ContainerAccess container = new ContainerAccess(); container.setContainerId("789443"); container.setPermission(Arrays.asList("read")); // Construct the account access object. AccountAccess account = new AccountAccess(); account.setPermission(Arrays.asList("read")); // Construct the user access object. UserAccess userAccess = new UserAccess(); userAccess.setEmailAddress("username@example.com"); userAccess.setAccountAccess(account); userAccess.setContainerAccess(Arrays.asList(container)); try { UserAccess response = tagmanager.accounts(). permissions().update("123456", "00123456789", userAccess).execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } /* * The results of the update method are stored in the response object. * The following code shows how to access the updated name and fingerprint. */ System.out.println("Updated Name = " + response.getName()); System.out.println("Updated Fingerprint = " + response.getFingerprint());
Python
使用 Python 客户端库。
# Note: This code assumes you have an authorized tagmanager service object. # This request updates a user's permissions to access a GTM account. try: response = tagmanager.accounts().permissions().update( accountId='123456', permissionId='00123456789', body={ 'emailAddress': 'username@example.com', 'accountAccess': { 'permission': [ 'read' ] }, 'containerAccess': { 'containerId': '54321', 'permission': [ 'read' ] } } ).execute() except TypeError, error: # Handle errors in constructing a query. print 'There was an error in constructing your query : %s' % error except HttpError, error: # Handle API errors. print ('There was an API error : %s : %s' % (error.resp.status, error.resp.reason)) # The results of the update method are stored in the response object. # The following code shows how to access the updated name and fingerprint. print 'Updated Name = %s' % response.get('name') print 'Updated Fingerprint = %s' % response.get('fingerprint')
立即试用!
请使用下面的 API Explorer 针对实际数据调用此方法,并查看响应。