注意:此开发者网站正在向 developers.google.com/tag-platform 迁移,2021 年 9 月 30 日起系统会将您重定向到新的网址

Permissions:list

需要授权

列出有权访问该帐号的所有用户及其各自获得的帐号和容器访问权限。 立即试用查看示例

请求

HTTP 请求

GET https://www.googleapis.com/tagmanager/v1/accounts/accountId/permissions

参数

参数名称 说明
路径参数
accountId string GTM 帐号 ID。 @required tagmanager.accounts.permissions.list

授权

此请求需要获得下列范围的授权(详细了解身份验证和授权)。

范围
https://www.googleapis.com/auth/tagmanager.manage.users

请求正文

请勿使用此方法提供请求正文。

响应

如果成功,此方法将返回采用以下结构的响应正文:

{
  "userAccess": [
    accounts.permissions Resource
  ]
}
属性名称 说明 备注
userAccess[] list GTM 帐号的所有 GTM 帐号用户。

示例

注意:此方法的代码示例并未列出所有受支持的编程语言(请参阅客户端库页面,查看受支持的语言列表)。

Java

使用 Java 客户端库

/*
 * Note: This code assumes you have an authorized tagmanager service object.
 */

/*
 * This request lists all permissions for the authorized user.
 */
try {
  ListAccountUsersResponse permissions =
      tagmanager.accounts().permissions().list("123456").execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

/*
 * The results of the list method are stored in the permissions object.
 * The following code shows how to iterate through them.
 */
for (UserAccess userAccess : permissions.getUserAccess()) {
  System.out.println("Account Id = " + userAccess.getAccountId());
  System.out.println("Permission Id = " + userAccess.getPermissionId());
  System.out.println("Email Address = " + userAccess.getEmailAddress());

  AccountAccess account = userAccess.getAccountAccess();
  for (String permission : account.getPermission()) {
    System.out.println("Account Permission = " + permission);
  }

  for (ContainerAccess container : userAccess.getContainerAccess()) {
    System.out.println("Container Id = " + container.getContainerId());
    for (String permission : account.getPermission()) {
      System.out.println("Container Permission = " + permission);
    }
  }
}

Python

使用 Python 客户端库

# Note: This code assumes you have an authorized tagmanager service object.

# This request lists all permissions for the authorized user.
try:
  permissions = tagmanager.accounts().permissions().list(
      accountId='123456').execute()
  print permissions
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 list method are stored in the permissions object.
# The following code shows how to iterate through them.
for userAccess in permissions.get('userAccess', []):
  print 'Account Id = %s' % userAccess.get('accountId')
  print 'Permissions Id = %s' % userAccess.get('permissionId')
  print 'Email Address = %s' % userAccess.get('emailAddress')

  account = userAccess.get('accountAccess', {})
  for permission in account.get('permission', []):
    print 'Account Permission = %s' % permission

  for container in userAccess.get('containerAccess', []):
    print 'Container Id = %s' % container.get('containerId')
    for permission in container.get('permission', []):
      print 'Container Permission = %s' % permission

试用一下!

请使用下面的 API Explorer 针对实际数据调用此方法,并查看响应。