Cần có sự cho phép
Cập nhật quyền tài khoản và vùng chứa của người dùng. Thử ngay hoặc xem ví dụ.
Yêu cầu
Yêu cầu HTTP
PUT https://www.googleapis.com/tagmanager/v1/accounts/accountId/permissions/permissionId
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. |
permissionId |
string |
Mã nhận dạng người dùng GTM. |
Ủ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
Trong nội dung yêu cầu, hãy cung cấp tài nguyên về quyền bằng các thuộc tính sau:
Tên tài sản | Giá trị | Nội dung mô tả | Ghi chú |
---|---|---|---|
Thuộc tính không bắt buộc | |||
accountAccess |
nested object |
Quyền truy cập tài khoản GTM. | có thể ghi |
accountAccess.permission[] |
list |
Danh sách quyền đối với tài khoản. Các quyền hợp lệ đối với tài khoản là read và manage . |
có thể ghi |
containerAccess[] |
list |
Quyền truy cập vào vùng chứa Trình quản lý thẻ của Google (GTM). | có thể ghi |
containerAccess[].containerId |
string |
Mã vùng chứa Trình quản lý thẻ của Google (GTM). | có thể ghi |
containerAccess[].permission[] |
list |
Danh sách các quyền đối với Vùng chứa. Các quyền hợp lệ đối với vùng chứa là: read, edit, delete, publish . |
có thể ghi |
Phản hồi
Nếu thành công, phương thức này sẽ trả về một tài nguyên về quyền trong nội dung phản hồi.
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 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
Dùng thư viện ứng dụng 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')
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.