نیاز به مجوز دارد
مجوزهای کانتینر و حساب کاربر را به روز می کند. اکنون آن را امتحان کنید یا نمونه ای را ببینید .
درخواست
درخواست 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 |
درخواست بدن
در بدنه درخواست، یک منبع مجوز با ویژگی های زیر ارائه کنید:
نام ملک | ارزش | شرح | یادداشت |
---|---|---|---|
ویژگی های اختیاری | |||
accountAccess | nested object | مجوزهای دسترسی به حساب GTM | قابل نوشتن |
accountAccess. permission[] | list | لیست مجوزهای حساب مجوزهای حساب معتبر read و manage می شوند. | قابل نوشتن |
containerAccess[] | list | مجوزهای دسترسی به کانتینر GTM | قابل نوشتن |
containerAccess[]. containerId | string | شناسه کانتینر GTM. | قابل نوشتن |
containerAccess[]. permission[] | list | لیست مجوزهای کانتینر مجوزهای کانتینر معتبر عبارتند از: read, edit, delete, publish . | قابل نوشتن |
واکنش
در صورت موفقیت آمیز بودن، این روش یک منبع Permissions را در بدنه پاسخ باز می گرداند.
مثال ها
توجه: نمونههای کد موجود برای این روش همه زبانهای برنامهنویسی پشتیبانیشده را نشان نمیدهند (برای فهرست زبانهای پشتیبانیشده به صفحه کتابخانههای سرویس گیرنده مراجعه کنید).
جاوا
از کتابخانه سرویس گیرنده جاوا استفاده می کند.
/* * 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());
پایتون
از کتابخانه کلاینت پایتون استفاده می کند.
# 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')
آن را امتحان کنید!
از APIs Explorer زیر برای فراخوانی این روش در دادههای زنده و دیدن پاسخ استفاده کنید.