Cần có sự cho phép
Liệt kê tất cả người dùng có quyền truy cập vào tài khoản, cùng với quyền cấp tài khoản và cấp vùng chứa cho từng người dùng. Thử ngay hoặc xem ví dụ.
Yêu cầu
Yêu cầu HTTP
GET https://www.googleapis.com/tagmanager/v1/accounts/accountId/permissions
Các tham số
Tên thông số | Giá trị | Nội dung mô tả |
---|---|---|
Tham số đường dẫn | ||
accountId |
string |
Mã tài khoản GTM. @tagmanager.accounts.permissions.list được yêu cầu |
Ủy quyền
Yêu cầu này cần được uỷ quyền với phạm vi sau (đọc thêm về quy trình xác thực và uỷ quyền).
Phạm vi |
---|
https://www.googleapis.com/auth/tagmanager.manage.users |
Nội dung yêu cầu
Đừng cung cấp nội dung yêu cầu bằng phương thức này.
Phản hồi
Nếu thành công, phương thức này sẽ trả về một nội dung phản hồi có cấu trúc như sau:
{ "userAccess": [ accounts.permissions Resource ] }
Tên tài sản | Giá trị | Nội dung mô tả | Ghi chú |
---|---|---|---|
userAccess[] |
list |
Tất cả Người dùng tài khoản GTM của một tài khoản GTM. |
Ví dụ
Lưu ý: Các đoạn mã mẫu của phương thức này không phải là ví dụ cho mọi ngôn ngữ lập trình được hỗ trợ (xem trang thông tin về các thư viện dùng cho ứng dụng để biết danh sách các ngôn ngữ được hỗ trợ).
Java
Sử dụng thư viện ứng dụng 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
Dùng thư viện ứng dụng 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
Hãy dùng thử!
Hãy sử dụng APIs Explorer bên dưới để gọi phương thức này trên dữ liệu trực tiếp và xem phản hồi.