認証が必要です
ユーザーがアクセスできるすべての GTM アカウントを一覧表示します。 今すぐ試すまたは例を見る。
リクエスト
HTTP リクエスト
GET https://www.googleapis.com/tagmanager/v1/accounts
承認
このリクエストは、少なくとも次のうち 1 つのスコープでの承認が必要です(認証と承認の詳細をご確認ください)。
範囲 |
---|
https://www.googleapis.com/auth/tagmanager.readonly |
https://www.googleapis.com/auth/tagmanager.manage.accounts |
https://www.googleapis.com/auth/tagmanager.edit.containers |
リクエスト本文
このメソッドをリクエストの本文に含めないでください。
レスポンス
成功すると、このメソッドは次の構造を含むレスポンスの本文を返します。
{ "accounts": [ accounts Resource ] }
プロパティ名 | 値 | 説明 | メモ |
---|---|---|---|
accounts[] |
list |
ユーザーがアクセス権を持つ GTM アカウントのリスト。 |
例
注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。
Java
Java クライアント ライブラリを使用します。
/* * Note: This code assumes you have an authorized tagmanager service object. */ /* * This request lists all accounts for the authorized user. */ try { ListAccountsResponse accounts = tagmanager.accounts().list().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 accounts object. * The following code show how to iterate through them. */ for (Account account : accounts.getAccounts()) { System.out.println("Account Id = " + account.getAccountId()); System.out.println("Account Name = " + account.getName()); System.out.println("Account Share Data = " + account.getShareData()); System.out.println("Account Fingerprint = " + account.getFingerprint()); }
Python
Python クライアント ライブラリを使用します。
# Note: This code assumes you have an authorized tagmanager service object. # This request lists all accounts for the authorized user. try: accounts = tagmanager.accounts().list().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 dir(error) print ('There was an API error : %s : %s' % (error.resp.status, error.resp.reason)) # The results of the list method are stored in the accounts object. # The following code shows how to iterate through them. for account in accounts.get('accounts', []): print 'Account Id = %s' % account.get('accountId') print 'Account Name = %s' % account.get('name') print 'Account Share Data = %s' % account.get('shareData') print 'Account Fingerprint = %s' % account.get('fingerprint')
試してみよう:
以下の API Explorer を使用して、ライブデータに対してこのメソッドを呼び出し、レスポンスを確認してください。