Google Workspace সদস্যতা তালিকাভুক্ত করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
এই পৃষ্ঠাটি ব্যাখ্যা করে যে কীভাবে subscriptions.list()
পদ্ধতি ব্যবহার করে Google Workspace সাবস্ক্রিপশনের তালিকা করতে হয়।
আপনি যখন ব্যবহারকারীর প্রমাণীকরণের সাথে এই পদ্ধতিটি কল করেন, তখন পদ্ধতিটি ব্যবহারকারীর দ্বারা অনুমোদিত সাবস্ক্রিপশনের একটি তালিকা প্রদান করে। আপনি যখন অ্যাপ প্রমাণীকরণ ব্যবহার করেন, পদ্ধতিটি এমন একটি তালিকা ফেরত দিতে পারে যাতে অ্যাপের জন্য কোনো সদস্যতা রয়েছে।
পূর্বশর্ত
অ্যাপস স্ক্রিপ্ট
- একটি Apps স্ক্রিপ্ট প্রকল্প:
পাইথন
- পাইথন 3.6 বা তার বেশি
- পাইপ প্যাকেজ ম্যানেজমেন্ট টুল
- পাইথনের জন্য সর্বশেষ Google ক্লায়েন্ট লাইব্রেরি। এগুলি ইনস্টল বা আপডেট করতে, আপনার কমান্ড-লাইন ইন্টারফেসে নিম্নলিখিত কমান্ডটি চালান:
pip3 install --upgrade google-api-python-client google-auth-oauthlib
- একটি Google Workspace সদস্যতা। একটি তৈরি করতে, একটি সদস্যতা তৈরি করুন দেখুন।
প্রমাণীকরণ প্রয়োজন:
- ব্যবহারকারীর প্রমাণীকরণের জন্য, সাবস্ক্রিপশনের জন্য অন্তত একটি ইভেন্ট প্রকারকে সমর্থন করে এমন একটি সুযোগ প্রয়োজন৷ একটি সুযোগ শনাক্ত করতে, ইভেন্টের ধরন অনুসারে স্কোপগুলি দেখুন।
- অ্যাপ প্রমাণীকরণের জন্য,
chat.bot
সুযোগ প্রয়োজন (শুধুমাত্র Google Chat অ্যাপ)।
একটি ব্যবহারকারী দ্বারা অনুমোদিত সদস্যতা তালিকা
সদস্যতা তালিকাভুক্ত করতে, আপনাকে অন্তত একটি ইভেন্ট প্রকার দ্বারা ফিল্টার করতে হবে৷ আপনি এক বা একাধিক লক্ষ্য সংস্থান দ্বারা আপনার ক্যোয়ারী ফিল্টার করতে পারেন। সমর্থিত ক্যোয়ারী ফিল্টার সম্পর্কে জানতে, list()
পদ্ধতির ডকুমেন্টেশন দেখুন।
নিম্নলিখিত কোড নমুনা ইভেন্টের ধরন এবং লক্ষ্য সংস্থান দ্বারা ফিল্টার করা Subscription
অবজেক্টের একটি অ্যারে প্রদান করে। যখন একজন ব্যবহারকারী হিসাবে প্রমাণীকরণ করা হয়, তখন পদ্ধতিটি শুধুমাত্র সাবস্ক্রিপশনের একটি তালিকা প্রদান করে যা ব্যবহারকারী অ্যাপটিকে তৈরি করার জন্য অনুমোদিত করে।
একটি নির্দিষ্ট ইভেন্টের ধরন এবং লক্ষ্য সংস্থানের জন্য সদস্যতা তালিকাভুক্ত করতে:
অ্যাপস স্ক্রিপ্ট
আপনার Apps স্ক্রিপ্ট প্রকল্পে, listSubscriptions
নামে একটি নতুন স্ক্রিপ্ট ফাইল তৈরি করুন এবং নিম্নলিখিত কোড যোগ করুন:
function listSubscriptions() {
// Filter for event type (required).
const eventType = 'EVENT_TYPE';
// Filter for target resource (optional).
const targetResource = 'TARGET_RESOURCE';
const filter = `event_types:"${eventType}" AND target_resource="${targetResource}"`
// Call the Workspace Events API using the advanced service.
const response = WorkspaceEvents.Subscriptions.list({ filter });
console.log(response);
}
নিম্নলিখিতগুলি প্রতিস্থাপন করুন:
-
EVENT_TYPE
: CloudEvents স্পেসিফিকেশন অনুযায়ী একটি ইভেন্টের ধরন ফরম্যাট করা হয়েছে। উদাহরণস্বরূপ, Google চ্যাট স্পেসে নতুন সদস্যতা নিয়ে ইভেন্টগুলি গ্রহণকারী সদস্যতাগুলির জন্য ফিল্টার করতে, google.workspace.chat.message.v1.created
। -
TARGET_RESOURCE
: একটি টার্গেট রিসোর্স , এটির সম্পূর্ণ রিসোর্স নাম হিসাবে ফর্ম্যাট করা হয়েছে। উদাহরণস্বরূপ, একটি Google চ্যাট স্পেসের জন্য সদস্যতা দ্বারা ফিল্টার করতে, //chat.googleapis.com/spaces/ SPACE_ID
ব্যবহার করুন যেখানে spaces/ SPACE_ID
Space
রিসোর্সের জন্য name
ক্ষেত্র প্রতিনিধিত্ব করে।
সদস্যতা তালিকাভুক্ত করতে, আপনার Apps স্ক্রিপ্ট প্রকল্পে ফাংশন listSubscriptions
চালান।
পাইথন
আপনার কাজের ডিরেক্টরিতে, list_subscriptions.py
নামে একটি ফাইল তৈরি করুন এবং নিম্নলিখিত কোড যোগ করুন:
"""List subscriptions."""
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
# Specify required scopes.
SCOPES = ['SCOPE']
# Authenticate with Google Workspace and get user authentication.
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)
CREDENTIALS = flow.run_local_server()
# Call the Workspace Events API using the service endpoint.
service = build(
'workspaceevents',
'v1',
credentials=CREDENTIALS,
)
# Filter for event type (required).
EVENT_TYPE = 'EVENT_TYPE'
# Filter for target resource (optional).
TARGET_RESOURCE = 'TARGET_RESOURCE'
FILTER = f'event_types:"{EVENT_TYPE}" AND target_resource="{TARGET_RESOURCE}"'
response = service.subscriptions().list(filter=FILTER).execute()
print(response)
নিম্নলিখিতগুলি প্রতিস্থাপন করুন:
-
SCOPE
: একটি OAuth স্কোপ যা সদস্যতা থেকে অন্তত একটি ইভেন্ট প্রকারকে সমর্থন করে । উদাহরণস্বরূপ, যদি আপনার সদস্যতা ইভেন্টগুলি একটি আপডেট করা চ্যাট স্পেস পায়, https://www.googleapis.com/auth/chat.spaces.readonly
। -
EVENT_TYPE
: CloudEvents স্পেসিফিকেশন অনুযায়ী একটি ইভেন্টের ধরন ফরম্যাট করা হয়েছে। উদাহরণস্বরূপ, Google চ্যাট স্পেসে নতুন সদস্যতা নিয়ে ইভেন্টগুলি গ্রহণকারী সদস্যতাগুলির জন্য ফিল্টার করতে, google.workspace.chat.message.v1.created
। -
TARGET_RESOURCE
: একটি টার্গেট রিসোর্স , এটির সম্পূর্ণ রিসোর্স নাম হিসাবে ফর্ম্যাট করা হয়েছে। উদাহরণস্বরূপ, একটি Google চ্যাট স্পেসের জন্য সদস্যতা দ্বারা ফিল্টার করতে, //chat.googleapis.com/spaces/ SPACE_ID
ব্যবহার করুন যেখানে spaces/ SPACE_ID
Space
রিসোর্সের জন্য name
ক্ষেত্র প্রতিনিধিত্ব করে।
আপনার কাজের ডিরেক্টরিতে, নিশ্চিত করুন যে আপনি আপনার OAuth ক্লায়েন্ট আইডি শংসাপত্রগুলি সংরক্ষণ করেছেন এবং ফাইলটির নাম দিয়েছেন credentials.json
। কোড নমুনা এই JSON ফাইলটি Google Workspace-এর সাথে প্রমাণীকরণ করতে এবং ব্যবহারকারীর শংসাপত্র পেতে ব্যবহার করে। নির্দেশাবলীর জন্য, OAuth ক্লায়েন্ট আইডি শংসাপত্র তৈরি করুন দেখুন।
সদস্যতা তালিকাভুক্ত করতে, আপনার টার্মিনালে নিম্নলিখিত চালান:
python3 list_subscriptions.py
Google Workspace Events API আপনার প্রশ্নের ফিল্টারের সাথে মেলে এমন Subscription
অবজেক্টের পেজিনেটেড অ্যারে প্রদান করে।
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-26 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-08-26 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis page provides instructions on how to list Google Workspace subscriptions using the \u003ccode\u003esubscriptions.list()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eThe method returns a list of authorized subscriptions when using user authentication and may return any app subscription when using app authentication.\u003c/p\u003e\n"],["\u003cp\u003eCode samples are provided for both Apps Script and Python to demonstrate listing subscriptions based on event type and target resource.\u003c/p\u003e\n"],["\u003cp\u003ePrerequisites include having a Google Workspace subscription, proper authentication and setup for the chosen scripting language.\u003c/p\u003e\n"],["\u003cp\u003eThe response is a paginated array of \u003ccode\u003eSubscription\u003c/code\u003e objects matching the query filter.\u003c/p\u003e\n"]]],["The `subscriptions.list()` method retrieves Google Workspace subscriptions, returning user-authorized subscriptions with user authentication or any app subscriptions with app authentication. Listing subscriptions requires filtering by event type and optionally by target resource. Apps Script and Python examples detail this process: defining event type and target resource filters, setting OAuth scopes, and running the code to retrieve and print a filtered array of `Subscription` objects using the Workspace Events API. User or app authentication is required.\n"],null,["# List Google Workspace subscriptions\n\nThis page explains how to list Google Workspace subscriptions using the\n[`subscriptions.list()`](/workspace/events/reference/rest/v1/subscriptions/list)\nmethod.\n\nWhen you call this method with user authentication, the method returns\na list of subscriptions authorized by the user. When you use app authentication,\nthe method can return a list that contains any subscription for the app.\n\nPrerequisites\n-------------\n\n### Apps Script\n\n- \u003cbr /\u003e\n\n A Google Workspace subscription. To create one, see [Create a subscription](/workspace/events/guides/create-subscription).\n\n \u003cbr /\u003e\n\n- Requires user authentication with one or more\n [scopes that support all event types for\n the subscription](/workspace/events/guides/auth#scopes-event-type).\n\n | **Note:** To run the code sample in this guide, you must use the same [OAuth client\n | ID credentials](/workspace/events/guides/create-subscription#create-oauth) that you used to create the subscription.\n\n\u003c!-- --\u003e\n\n- An Apps Script project:\n - Use your Google Cloud project instead of the default one created automatically by Apps Script.\n - For all scopes that you added to configure the OAuth consent screen, you must also add the scopes to the `appsscript.json` file in your Apps Script project. For example, if you specified the `chat.messages` scope, then add the following: \n\n ```console\n \"oauthScopes\": [\n \"https://www.googleapis.com/auth/chat.messages\"\n ]\n \n ```\n - [Enable](/apps-script/guides/services/advanced#enable_advanced_services) the `Google Workspace Events` advanced service.\n\n### Python\n\n- Python 3.6 or greater\n- The [pip](https://pypi.org/project/pip/) package management tool\n- The latest Google client libraries for Python. To install or update them, run the following command in your command-line interface: \n\n ```console\n pip3 install --upgrade google-api-python-client google-auth-oauthlib\n \n ```\n\n\u003c!-- --\u003e\n\n- \u003cbr /\u003e\n\n A Google Workspace subscription. To create one, see [Create a subscription](/workspace/events/guides/create-subscription).\n\n \u003cbr /\u003e\n\n- Requires [authentication](/workspace/events/guides/auth):\n\n - For user authentication, requires a scope that supports at least one of the event types for the subscription. To identify a scope, see [Scopes by event type](/workspace/events/guides/auth#scopes-event-type). **Note:** To run the code sample in this guide, you must use the same [OAuth\n | client ID credentials](/workspace/events/guides/create-subscription#create-oauth) that you used to create the subscription.\n - For app authentication, requires the `chat.bot` scope (Google Chat apps only).\n\nList subscriptions authorized by a user\n---------------------------------------\n\nTo list subscriptions, you must filter by at least one event type. You can also\nfilter your query by one or more target resources. To learn about supported\nquery filters, see the [`list()` method\ndocumentation](/workspace/events/reference/rest/v1/subscriptions/list).\n\nThe following code sample returns an array of\n[`Subscription`](/workspace/events/reference/rest/v1/subscriptions) objects\nfiltered by event type and target resource. When authenticated as a user, the\nmethod only returns a list of subscriptions that the user authorized the app to\ncreate.\n\nTo list subscriptions for a specified event type and target resource: \n\n### Apps Script\n\n1. In your Apps Script project, create a new script file\n named `listSubscriptions` and add the following code:\n\n function listSubscriptions() {\n // Filter for event type (required).\n const eventType = &\u003cvar translate=\"no\"\u003e#39;EVENT_\u003c/var\u003eTYPE';\n\n // Filter for target resource (optional).\n const targetReso\u003cvar translate=\"no\"\u003eurce\u003c/var\u003e = 'TARGET_RESOURCE';\n\n const filter = `event_types:\"${eventType}\" AND target_resource=\"${targetResource}\"`\n\n // Call the Workspace Events API using the advanced service.\n const response = WorkspaceEvents.Subscriptions.list({ filter });\n console.log(response);\n }\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eEVENT_TYPE\u003c/var\u003e: An [event type](/workspace/events/reference/rest/v1/subscriptions#Subscription.FIELDS.event_types) formatted according to the CloudEvents specification. For example, to filter for subscriptions that receive events about new memberships to a Google Chat space, `google.workspace.chat.message.v1.created`.\n - \u003cvar translate=\"no\"\u003eTARGET_RESOURCE\u003c/var\u003e: A [target resource](/workspace/events/reference/rest/v1/subscriptions#Subscription.FIELDS.target_resource), formatted as its full resource name. For example, to filter by subscriptions for a Google Chat space, use `//chat.googleapis.com/spaces/`\u003cvar translate=\"no\"\u003eSPACE_ID\u003c/var\u003e where `spaces/`\u003cvar translate=\"no\"\u003eSPACE_ID\u003c/var\u003e represents the [`name`](/workspace/chat/api/reference/rest/v1/spaces#Space.FIELDS.name) field for the `Space` resource.\n2. To list subscriptions, run the function `listSubscriptions` in\n your Apps Script project.\n\n### Python\n\n1. In your working directory, create a file named `list_subscriptions.py`\n and add the following code:\n\n \"\"\"List subscriptions.\"\"\"\n\n from google_auth_oauthlib.flow import InstalledAppFlow\n from googleapiclient.discovery import build\n\n # Specif\u003cvar translate=\"no\"\u003ey req\u003c/var\u003euired scopes.\n SCOPES = ['SCOPE']\n\n # Authenticate with Google Workspace and get user authentication.\n flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)\n CREDENTIALS = flow.run_local_server()\n\n # Call the Workspace Events API using the service endpoint.\n service = build(\n 'workspaceevents',\n 'v1',\n credentials=CRED\u003cvar translate=\"no\"\u003eENTIALS\u003c/var\u003e,\n )\n\n # Filter for event type (required).\n EVENT_TYPE = 'EVENT_T\u003cvar translate=\"no\"\u003eYPE'\u003c/var\u003e\n\n # Filter for target resource (optional).\n TARGET_RESOURCE = 'TARGET_RESOURCE'\n\n FILTER = f'event_types:\"{EVENT_TYPE}\" AND target_resource=\"{TARGET_RESOURCE}\"'\n response = service.subscriptions().list(filter=FILTER).execute()\n print(response)\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSCOPE\u003c/var\u003e: An OAuth scope that [supports at least\n one event type from the subscription](/workspace/events/guides/auth#scopes-event-type). For example, if your subscription receives events an updated Chat space, `https://www.googleapis.com/auth/chat.spaces.readonly`.\n - \u003cvar translate=\"no\"\u003eEVENT_TYPE\u003c/var\u003e: An [event type](/workspace/events/reference/rest/v1/subscriptions#Subscription.FIELDS.event_types) formatted according to the CloudEvents specification. For example, to filter for subscriptions that receive events about new memberships to a Google Chat space, `google.workspace.chat.message.v1.created`.\n - \u003cvar translate=\"no\"\u003eTARGET_RESOURCE\u003c/var\u003e: A [target resource](/workspace/events/reference/rest/v1/subscriptions#Subscription.FIELDS.target_resource), formatted as its full resource name. For example, to filter by subscriptions for a Google Chat space, use `//chat.googleapis.com/spaces/`\u003cvar translate=\"no\"\u003eSPACE_ID\u003c/var\u003e where `spaces/`\u003cvar translate=\"no\"\u003eSPACE_ID\u003c/var\u003e represents the [`name`](/workspace/chat/api/reference/rest/v1/spaces#Space.FIELDS.name) field for the `Space` resource.\n2. In your working directory, make sure you've stored your OAuth client ID\n credentials and named the file `credentials.json`. The code sample uses this JSON\n file to authenticate with Google Workspace and get user credentials. For instructions,\n see [Create OAuth client ID\n credentials](/workspace/events/guides/create-subscription#create-oauth).\n\n3. To list subscriptions, run the following in your terminal:\n\n python3 list_subscriptions.py\n\nThe Google Workspace Events API returns a [paginated array of `Subscription`\nobjects](/workspace/events/reference/rest/v1/subscriptions/list#response-body)\nthat match the filter for your query.\n\nRelated topics\n--------------\n\n- [Update or renew a subscription](/workspace/events/guides/update-subscription)\n- [Resolve errors and reactivate a subscription](/workspace/events/guides/reactivate-subscription)\n- [Delete a subscription](/workspace/events/guides/delete-subscription)\n- [Get a subscription](/workspace/events/guides/get-subscription)\n- [Create a subscription](/workspace/events/guides/create-subscription)"]]