Permissions: update

ต้องมีการให้สิทธิ์

อัปเดตบัญชีและสิทธิ์ใช้งานคอนเทนเนอร์ของผู้ใช้ ลองใช้เลยหรือดูตัวอย่าง

ส่งคำขอ

คำขอ HTTP

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

พารามิเตอร์

ชื่อพารามิเตอร์ ค่า คำอธิบาย
พารามิเตอร์เส้นทาง
accountId string รหัสบัญชี GTM
permissionId string รหัสผู้ใช้ GTM

การให้สิทธิ์

คำขอนี้ต้องได้รับสิทธิ์ด้วยขอบเขตต่อไปนี้ (อ่านเพิ่มเติมเกี่ยวกับการตรวจสอบสิทธิ์และการให้สิทธิ์)

ขอบเขต
https://www.googleapis.com/auth/tagmanager.manage.users

เนื้อหาของคำขอ

ในเนื้อหาคำขอ ให้ระบุทรัพยากรสิทธิ์พร้อมด้วยพร็อพเพอร์ตี้ต่อไปนี้

ชื่อพร็อพเพอร์ตี้ ค่า คำอธิบาย Notes
พร็อพเพอร์ตี้ที่ไม่บังคับ
accountAccess nested object สิทธิ์การเข้าถึงบัญชี GTM เขียนได้
accountAccess.permission[] list รายการสิทธิ์ของบัญชี สิทธิ์ที่ถูกต้องของบัญชีคือreadและmanage เขียนได้
containerAccess[] list สิทธิ์การเข้าถึงคอนเทนเนอร์ GTM เขียนได้
containerAccess[].containerId string รหัสคอนเทนเนอร์ GTM เขียนได้
containerAccess[].permission[] list รายการสิทธิ์สำหรับคอนเทนเนอร์ สิทธิ์ของคอนเทนเนอร์ที่ถูกต้องคือ read, edit, delete, publish เขียนได้

คำตอบ

หากสำเร็จ เมธอดนี้จะแสดงทรัพยากรสิทธิ์ในเนื้อหาการตอบสนอง

ตัวอย่าง

หมายเหตุ: ตัวอย่างโค้ดที่มีสำหรับวิธีการนี้ไม่ได้แสดงถึงภาษาโปรแกรมที่รองรับทั้งหมด (ดูรายการภาษาที่รองรับได้ในหน้าไลบรารีของไคลเอ็นต์)

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 ด้านล่างเพื่อเรียกใช้เมธอดนี้กับข้อมูลแบบเรียลไทม์และดูการตอบสนอง