Permissions: list

Requires authorization

List all users that have access to the account along with account and container permissions granted to each of them. Try it now or see an example.

Request

HTTP request

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

Parameters

Parameter name Value Description
Path parameters
accountId string The GTM Account ID. @required tagmanager.accounts.permissions.list

Authorization

This request requires authorization with the following scope (read more about authentication and authorization).

Scope
https://www.googleapis.com/auth/tagmanager.manage.users

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a response body with the following structure:

{
  "userAccess": [
    accounts.permissions Resource
  ]
}
Property name Value Description Notes
userAccess[] list All GTM AccountUsers of a GTM Account.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

/*
 * 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

Uses the Python client library.

# 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

Try it!

Use the APIs Explorer below to call this method on live data and see the response.