इसके लिए, अनुमति लेना ज़रूरी है
उपयोगकर्ता के खाते और कंटेनर की अनुमतियां बनाता है. इसे अभी आज़माएं या उदाहरण देखें.
अनुरोध
एचटीटीपी अनुरोध
POST https://www.googleapis.com/tagmanager/v1/accounts/accountId/permissions
पैरामीटर
पैरामीटर का नाम | वैल्यू | ब्यौरा |
---|---|---|
पाथ पैरामीटर | ||
accountId |
string |
GTM खाता आईडी. |
अनुमति देना
इस अनुरोध के लिए नीचे दिए गए दायरे के साथ अनुमति की ज़रूरत है (पुष्टि करने और अनुमति देने के बारे में ज़्यादा पढ़ें).
स्कोप |
---|
https://www.googleapis.com/auth/tagmanager.manage.users |
अनुरोध का मुख्य भाग
अनुरोध के मुख्य हिस्से में, इन प्रॉपर्टी के साथ अनुमतियों से जुड़ा संसाधन दें:
प्रॉपर्टी का नाम | वैल्यू | ब्यौरा | ज़रूरी जानकारी |
---|---|---|---|
ज़रूरी प्रॉपर्टी | |||
accountAccess |
nested object |
GTM खाते के ऐक्सेस की अनुमतियां. | लिखने योग्य |
accountAccess.permission[] |
list |
खाता अनुमतियों की सूची. खाते की मान्य अनुमतियां read और manage हैं. |
लिखने योग्य |
emailAddress |
string |
उपयोगकर्ता का ईमेल पता. | लिखने योग्य |
वैकल्पिक प्रॉपर्टी | |||
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 authorizes a new user to access a GTM account. */ // Construct the container access object. ContainerAccess container = new ContainerAccess(); container.setContainerId("54321"); 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().create("12345", userAccess).execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } /* * The results of the create method are stored in the response object. * The following code shows how to access the created id. */ System.out.println("Permissions Id = " + response.getPermissionId());
Python
Python क्लाइंट लाइब्रेरी का इस्तेमाल करता हो.
# Note: This code assumes you have an authorized tagmanager service object. # This request authorizes a new user to access a GTM account. try: permissions = tagmanager.accounts().permissions().create( accountId='123456', 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))
इसे आज़माएं!
इस तरीके को लाइव डेटा पर कॉल करने और रिस्पॉन्स देखने के लिए, नीचे दिए गए एपीआई एक्सप्लोरर का इस्तेमाल करें.