دسترسی به Google Cloud Search API را پیکربندی کنید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
قبل از اینکه بتوانید مستقیماً یا از طریق یک SDK از این API استفاده کنید، باید دسترسی به Google Cloud Search API را پیکربندی کنید. این سند مراحل مورد نیاز برای استفاده از Google Cloud Search API REST API را پوشش می دهد.
1. یک پروژه API ایجاد کنید
برای فعال کردن API، ابتدا باید یک پروژه Google Cloud ایجاد کنید. این پروژه اساس ایجاد، فعال کردن و استفاده از همه سرویسهای Google Cloud، از جمله مدیریت APIها، فعال کردن صورتحساب، افزودن و حذف همکاران و مدیریت مجوزها را تشکیل میدهد.
در بالای صفحه، روی arrow_drop_down در سمت راست "Google Cloud Console" کلیک کنید. گفتگوی لیست پروژه های فعلی ظاهر می شود.
روی NEW PROJECT کلیک کنید. صفحه "پروژه جدید" ظاهر می شود.
نام پروژه را در قسمت Project Name وارد کنید.
(اختیاری) برای ویرایش شناسه پروژه روی Edit کلیک کنید. شناسه پروژه پس از ایجاد پروژه قابل تغییر نیست، بنابراین شناسه ای را انتخاب کنید که نیازهای شما را برای طول عمر پروژه برآورده کند.
برای مرور مکانهای پروژه، روی BROWSE کلیک کنید.
روی یک مکان برای پروژه خود کلیک کنید و روی انتخاب کلیک کنید.
روی ایجاد کلیک کنید. کنسول به صفحه داشبورد هدایت می شود. پروژه در عرض چند دقیقه ایجاد می شود.
شما باید Google Cloud Search API را فعال کنید و یک حساب کاربری برای دریافت اعتبار ایجاد کنید.
برای اطمینان از اینکه در پروژه جدید ایجاد شده هستید، روی نماد arrow_drop_down در سمت راست بنر کنسول Google Cloud کلیک کنید و پروژه تازه ایجاد شده خود را انتخاب کنید.
روی ENABLE APIS AND SERVICES کلیک کنید. صفحه "Welcome to API Library" ظاهر می شود.
در کنسول Google Cloud ، روی اعتبارنامه ها در پیمایش سمت چپ کلیک کنید. صفحه اعتبارنامه ظاهر می شود.
از لیست کشویی Create credentials ، حساب سرویس را انتخاب کنید. صفحه "ایجاد حساب سرویس" ظاهر می شود.
نامی را در قسمت نام حساب سرویس وارد کنید.
(اختیاری) شناسه حساب سرویس را ویرایش کنید.
روی ایجاد کلیک کنید. صفحه "مجوزهای حساب سرویس" ظاهر می شود.
روی Continue کلیک کنید. صفحه "اعطای دسترسی کاربران به این حساب سرویس" ظاهر می شود.
روی CREATE KEY کلیک کنید و روی Done کلیک کنید. گفتگوی "کلید خصوصی ذخیره شده در رایانه شما" ظاهر می شود و یک کپی از کلید خصوصی در رایانه شما بارگیری می شود.
از کنسول Google Cloud ، پروژه ای را که ایجاد کرده اید در بالای صفحه انتخاب کنید.
روی منوی پیمایش در سمت چپ بنر کنسول Google Cloud کلیک کنید.
روی IAM و Admin > حسابهای سرویس کلیک کنید.
در فهرست، در بخش «شناسه حساب سرویس»، آدرس ایمیل ایجاد شده را که حساب سرویسی را که پیکربندی کردهاید مشخص میکند، یادداشت کنید. این آدرس ایمیل هنگام افزودن منبع داده به جستجوی ابری استفاده می شود.
5. پشتیبانی از شخص ثالث را راه اندازی کنید
قبل از اینکه بتوانید با هر API دیگری Cloud Search تماس بگیرید، باید پشتیبانی شخص ثالث را برای Google Cloud Search راه اندازی کنید.
برای راه اندازی پشتیبانی شخص ثالث برای Cloud Search:
پروژه پلتفرم Cloud Search شما حاوی اطلاعات کاربری حساب سرویس است. با این حال، به خاطر مقداردهی اولیه پشتیبانی شخص ثالث، باید اعتبار برنامه وب را ایجاد کنید. برای دستورالعملهای مربوط به نحوه ایجاد اعتبارنامه برنامه وب، به ایجاد اعتبارنامه مراجعه کنید. پس از انجام این مرحله، باید یک شناسه مشتری و فایل مخفی مشتری داشته باشید.
روی تنظیمات کلیک کنید و User your own auth credentials را علامت بزنید.
شناسه مشتری و رمز سرویس گیرنده را از مرحله 1 وارد کنید.
روی Close کلیک کنید.
در قسمت scopes، https://www.googleapis.com/auth/cloud_search.settings را تایپ کنید و روی تأیید کلیک کنید. زمین بازی OAuth 2 یک کد مجوز را برمی گرداند.
روی کد مجوز تبادل برای توکنها کلیک کنید. یک توکن برگردانده می شود.
برای مقداردهی اولیه پشتیبانی شخص ثالث برای Cloud Search، از دستور curl زیر استفاده کنید. مطمئن شوید که [YOUR_ACCESS_TOKEN] با رمز به دست آمده در مرحله 2 جایگزین کنید.
در اینجا چند قدم بعدی وجود دارد که ممکن است بردارید:
اگر قصد دارید از Google Cloud Search با یک مخزن داده غیر Google، مانند Microsoft® SharePoint® استفاده کنید، باید یک منبع داده ایجاد کنید. برای دستورالعملهای مربوط به افزودن منبع داده، به افزودن منبع داده برای جستجو مراجعه کنید.
هنگامی که منبع داده خود را تنظیم کردید، می توانید طرحواره ای ایجاد و ثبت کنید تا شناسایی کنید جستجوی ابری Google چگونه باید داده ها را در مخزن نمایش دهد.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Configure access to the Google Cloud Search API\n\nYou must configure access to the Google Cloud Search API before you can\nuse this API either directly or through an SDK. This document\ncovers the steps required to use the Google Cloud Search API REST API.\n\n1. Create an API project\n------------------------\n\nTo enable the API, you must first create an Google Cloud project. This\nproject forms the basis for creating, enabling, and using all Google Cloud\nservices, including managing APIs, enabling billing, adding and\nremoving collaborators, and managing permissions.\n\n1. Open the [Google Cloud console](https://console.cloud.google.com/apis/dashboard).\n\n2. At the top of the page, click\n arrow_drop_down\n to the right of \"Google Cloud Console.\" A dialog listing current projects\n appears.\n\n3. Click **NEW PROJECT**. The \"New Project\" screen appears.\n\n4. Enter a project name in the **Project Name** field.\n\n5. (optional) Click **Edit** to edit the Project ID. The project ID can't be\n changed after the project is created, so choose an\n ID that meets your needs for the lifetime of the project.\n\n6. To browse locations for the project, click **BROWSE**.\n\n7. Click on a location for your project and click **Select**.\n\n8. Click **Create**. The console navigates to the Dashboard page. The project\n is created within a few minutes.\n\nFor further information on creating and managing projects, refer to\n[Creating and Managing Projects](https://support.google.com/cloud#topic=6158848).\n\n2. Enable the API\n-----------------\n\nYou need to enable the Google Cloud Search API and create a service account to\nobtain credentials.\n\n1. To ensure you are on the newly created project, click the arrow_drop_down icon to the right of the Google Cloud console banner and select your newly-created project.\n2. Click **ENABLE APIS AND SERVICES**. The \"Welcome to API Library\" page appears.\n3. Navigate to the [Google Cloud Search API](https://console.cloud.google.com/apis/api/cloudsearch.googleapis.com).\n4. Click **Enable**. The \"Overview\" page appears.\n\nFor further information on enabling and disabling APIs, refer to\n[Manage APIs in the Google Cloud console](https://support.google.com/cloud/answer/6326510)\n| **Note:** Different Cloud Search APIs require different accounts to execute (admin, service, and user). For further information, refer to the [reference documentation](/workspace/cloud-search/docs/reference) for the method you want to call.\n\n3. Create service account credentials\n-------------------------------------\n\n1. In the [Google Cloud console](https://console.cloud.google.com/apis/library), click **Credentials** in the left navigation. The Credential page appears.\n2. From the **Create credentials** drop-down list, select **Service account**. The \"Create service account\" page appears.\n3. Enter a name in the **Service account name** field.\n4. (optional) Edit the service account ID.\n5. Click **Create**. A \"Service account permissions\" screen appears.\n6. Click **Continue**. A \"Grant users access to this service account\" screen appears.\n7. Click **CREATE KEY** and click **Done**. A \"Private key saved to your computer\" dialog appears and a copy of the private key downloads to your computer.\n8. Click **Close**.\n\nFor further information on service accounts, refer to\n[Service accounts, web applications, and installed applications](https://support.google.com/cloud/answer/6158849#serviceaccounts)\n\n4. Identify email address\n-------------------------\n\n1. From the [Google Cloud console](https://console.cloud.google.com/apis/dashboard), select the project you created at the top of the page.\n2. Click the Navigation menu to the left of the Google Cloud console banner.\n3. Click **IAM and Admin** \\\u003e **Service accounts**.\n4. In the list, under \"Service account ID,\" make note of the generated email address that identifies the service account you configured. This email address is used when adding a data source to Cloud Search.\n\n5. Initialize third-party support\n---------------------------------\n\nBefore you can call any other Cloud Search APIs, you must initialize third-party\nsupport for Google Cloud Search.\n| **Note:** If you successfully executed the Cloud Search tutorial, you have already initialized third-party support for Cloud Search and can skip this step.\n\nTo initialize third-party support for Cloud Search:\n\n1. Your Cloud Search platform project contains service account credentials.\n However, for the sake of initializing third-party support, you must create web\n application credentials. For instructions on how to create web application\n credentials, refer to\n [Create credentials](/workspace/guides/create-credentials).\n Upon completing this step, you should have a client ID and client secret file.\n\n2. Use\n [Google's OAuth 2 playground](https://developers.google.com/oauthplayground/)\n to obtain an access token:\n\n 1. Click settings and check **User your own auth credentials**.\n 2. Enter the client ID and client secret from step 1.\n 3. Click **Close**.\n 4. In the scopes field, type `https://www.googleapis.com/auth/cloud_search.settings` and click **Authorize**. The OAuth 2 playground returns an authorization code.\n 5. Click **Exchange authorization code for tokens**. A token is returned.\n3. To initialize third-party support for Cloud Search, use the following curl\n command. Be sure to substitute `[YOUR_ACCESS_TOKEN]` with the token obtained in\n step 2.\n\n curl --request POST \\\n 'https://cloudsearch.googleapis.com/v1:initializeCustomer' \\\n --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \\\n --header 'Accept: application/json' \\\n --header 'Content-Type: application/json' \\\n --data '{}' \\\n --compressed\n\n If successful, the response body contains an instance of\n [`operation`](/workspace/cloud-search/docs/reference/rest/v1/operations#Operation). For\n example: \n\n {\n name: \"operations/customers/01b3fqdm/lro/AOIL6eBv7fEfiZ_hUSpm8KQDt1Mnd6dj5Ru3MXf-jri4xK6Pyb2-Lwfn8vQKg74pgxlxjrY\"\n }\n\n If unsuccessful, contact Cloud Search support.\n4. Use [operations.get](/workspace/cloud-search/docs/reference/rest/v1/operations/get) to verify that\n third-party support is initialized:\n\n curl \\\n 'https://cloudsearch.googleapis.com/v1/operations/customers/01b3fqdm/lro/AOIL6eBv7fEfiZ_hUSpm8KQDt1Mnd6dj5Ru3MXf-jri4xK6Pyb2-Lwfn8vQKg74pgxlxjrY?key=\n [YOUR_API_KEY]' \\\n --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \\\n --header 'Accept: application/json' \\\n --compressed\n\n When the third-party initialization is complete, it contains the\n field `done` set to `true`. For example: \n\n {\n name: \"operations/customers/01b3fqdm/lro/AOIL6eBv7fEfiZ_hUSpm8KQDt1Mnd6dj5Ru3MXf-jri4xK6Pyb2-Lwfn8vQKg74pgxlxjrY\"\n done: true\n }\n\nNext Steps\n----------\n\nHere are few next steps you might take:\n\n1. If you plan on using Google Cloud Search with a non-Google data repository,\n such as Microsoft® SharePoint®, you\n must create a data source. For instructions on\n adding a data source, refer to\n [Add a data source to search](https://support.google.com/a/answer/7056471).\n\n2. Once you set up your data source, you can\n [create and register schema](/workspace/cloud-search/docs/guides/schema-guide) to identify\n how Google Cloud Search should represent the data in the repository."]]