تنظیم مجوز
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Search Ads 360 API به همه درخواستها نیاز دارد که یک نشانه دسترسی OAuth 2.0 را برای احراز هویت مشخص کنند. میتوانید از هر گردش کار احراز هویت استاندارد OAuth 2.0 پیروی کنید تا رمز را تولید کنید و آن را به Search Ads 360 API ارسال کنید. ما گردش کار شرح داده شده در زیر را توصیه می کنیم زیرا برای آپلودهای تبدیل کاملاً خودکار و بارگیری گزارش مناسب است.
برای جایگزینهای گردش کار شرح داده شده در زیر، به استفاده از OAuth 2.0 برای برنامههای نصب شده یا استفاده از OAuth 2.0 برای برنامههای سرور به سرور مراجعه کنید. اگر از یک گردش کار جایگزین استفاده می کنید، هنگام درخواست کد مجوز OAuth 2.0، مقدار زیر را به عنوان پارامتر scope
مشخص کنید:
https://www.googleapis.com/auth/doubleclicksearch
اگر مسیر سرور به سرور را دنبال می کنید، حساب سرویس را به عنوان کاربر Search Ads 360 اضافه کنید.
گردش کار مجوز توصیه شده
- به کنسول API Google بروید و پروژه خود را انتخاب کنید.
اگر قبلاً یک پروژه Google API Console و اعتبارنامه OAuth ایجاد نکردهاید، دستورالعملهای ایجاد پروژه Google API Console و اعتبارنامه OAuth را برای مشتری خود دنبال کنید.
برای پیدا کردن شناسه مشتری OAuth و راز پروژه خود، موارد زیر را انجام دهید:
- صفحه اعتبارنامه را باز کنید.
- در ستون Name ، روی نام مشتری OAuth خود کلیک کنید.
- شناسه مشتری و راز در صفحه ذکر شده است.
- یک مرورگر وب باز کنید و با یک حساب Google که مجوز دسترسی به دادههای Search Ads 360 را دارد، وارد Google شوید .
این همان حساب Google است که مشتری API شما برای احراز هویت با Search Ads 360 استفاده میکند. اگر دارنده حساب Google شرکت شما را ترک کند و دسترسی Search Ads 360 را از حساب حذف کنید، باید این گردش کار مجوز را تکرار کنید و حساب Google دیگری را مشخص کنید. .
- با فراخوانی اسکریپت ابزار Search Ads 360 به شرح زیر، یک نشانه بهروزرسانی دریافت کنید:
sa360Api.py --login
این اسکریپت شما را از طریق فرآیند استفاده از شناسه مشتری Oauth و مخفی برای به دست آوردن یک توکن بهروزرسانی میبرد. نشانه تازهسازی فقط برای حساب Google که در مرحله قبل به آن وارد شدهاید معتبر است.
به عنوان بخشی از این فرآیند، اسکریپت یک URL تولید می کند و به شما دستور می دهد که URL را در یک مرورگر وب مشاهده کنید.
وقتی مرورگر از شما میخواهد که به مشتری OAuth اجازه دسترسی به دادههای Search Ads 360 را بدهید، مطمئن شوید که حساب Google که قبلاً به آن وارد شدهاید ظاهر شود. (اگر به چندین حساب Google وارد شده باشید، ممکن است با یک حساب دیگر مواجه شوید.)

در پایان فرآیند، اسکریپت sa360Api.py
یک رشته محدود شده با کاما را خروجی می دهد. مقدار اول شناسه مشتری است که شما ارائه کرده اید، مقدار دوم رمز مشتری است که ارائه کرده اید و مقدار سوم رمز تجدید است. در خروجی مثال زیر، نشانه رفرش با متن پررنگ است:
123456789123.apps.googleusercontent.com,ABCDEFGHIJKLMNOPQR_abcdef, 1/HIJklM01OPQR23NOP456rst890uvw
- شناسه سرویس گیرنده، رمز سرویس گیرنده، و توکن رفرش را در یک پایگاه داده پشتیبان یا مکان امن دیگری که برای برنامه شما قابل دسترسی است ذخیره کنید.
اگر میخواهید از sa360Api.py
برای ارسال نمونه درخواستهای JSON به Search Ads 360 API استفاده کنید، کل رشته محدود شده با کاما را در یک مکان مناسب نگه دارید. هر بار که اسکریپت را فراخوانی می کنید، کل رشته را به عنوان پارامتر ارسال می کنید.
- کدی را به برنامه خود اضافه کنید که کارهای زیر را انجام می دهد:
- از شناسه سرویس گیرنده، رمز سرویس گیرنده، و نشانه رفرش استفاده کنید تا یک نشانه دسترسی جدید OAuth 2.0 به دست آورید.
- با استفاده از رمز دسترسی تازه، درخواستها را به Search Ads 360 API ارسال کنید.
اگر از کتابخانه های سرویس گیرنده استفاده می کنید، بخش بعدی، راه اندازی برنامه ، نحوه افزودن این کد مجوز را به برنامه خود توضیح می دهد.
اگر از یکی از کتابخانههای سرویس گیرنده استفاده نمیکنید، برای دریافت پیشنهادات مربوط به دریافت رمز دسترسی جدید ، به استفاده از OAuth 2.0 برای برنامههای نصب شده مراجعه کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2024-11-08 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-11-08 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe Search Ads 360 API requires OAuth 2.0 access tokens for authentication, obtainable through standard OAuth 2.0 workflows or the recommended workflow outlined in the document.\u003c/p\u003e\n"],["\u003cp\u003eThe recommended workflow involves obtaining a refresh token using the provided utility script and storing it securely along with the client ID and secret.\u003c/p\u003e\n"],["\u003cp\u003eApplications should be designed to use the stored credentials to obtain fresh access tokens for API requests, as detailed in the "Set Up Your Application" section or relevant OAuth 2.0 documentation.\u003c/p\u003e\n"],["\u003cp\u003eAlternative workflows for installed or server-to-server applications are available with specific scope requirements and user management considerations.\u003c/p\u003e\n"]]],["The Search Ads 360 API requires OAuth 2.0 access tokens for authentication. The recommended workflow involves creating a Google API Console project and obtaining OAuth credentials. Users sign into a Google Account with Search Ads 360 access, then use the `sa360Api.py` script to generate a refresh token. The script outputs client ID, client secret, and refresh token. Store these securely, and use them in your application to obtain a fresh OAuth access token for API requests.\n"],null,["# Set Up Authorization\n\nThe Search Ads 360 API requires all requests to specify an [OAuth 2.0](/accounts/docs/OAuth2)\naccess token for authentication. You can follow any standard OAuth 2.0 authentication workflow\nto generate the token and pass it to the Search Ads 360 API. We recommend the workflow described\nbelow because it is suitable for fully automated conversion uploads and report downloads.\n\n\nFor alternatives to the workflow described below, see [Using\nOAuth 2.0 for Installed Applications](https://developers.google.com/accounts/docs/OAuth2InstalledApp) or\n[Using OAuth 2.0 for Server to Server Applications](https://developers.google.com/identity/protocols/OAuth2ServiceAccount). If you use an alternate workflow,\nspecify the following value as the `scope` parameter when you request an OAuth\n2.0 authorization code: \n\n`https://www.googleapis.com/auth/doubleclicksearch`\n\nIf you follow the server to server route, add the service account as a Search Ads 360 user.\n\nRecommended authorization workflow\n----------------------------------\n\n1. Go to the [Google API Console](https://console.cloud.google.com/) and select your project.\n\n\n If you haven't already created a Google API Console project and OAuth credentials, follow\n the instructions in [Create a Google API\n Console project and OAuth credentials for your client](/search-ads/v2/prereqs#project).\n\n To find your project's OAuth client ID and secret, do the following:\n 1. Open the [Credentials page](https://console.cloud.google.com/apis/credentials).\n 2. In the **Name** column, click the name of your OAuth client.\n 3. The client ID and secret are listed on the page.\n2. Open a web browser and [sign into Google](https://accounts.google.com/ServiceLogin)with a Google Account that [has\n permission to access data](/search-ads/v2/prereqs#permissions) in Search Ads 360.\n\n This is the Google Account your API client will use to authenticate with Search Ads 360.\n If the Google Account holder leaves your company and you remove Search Ads 360 access\n from the account, you will need to repeat this authorization workflow and specify a\n different Google Account.\n3. Obtain a refresh token by invoking the [Search Ads 360 utility script](/search-ads/v2/prereqs#ds3py) as follows:\n\n\n `sa360Api.py --login`\n\n\n The script takes you through the process of using the Oauth client ID and secret to\n obtain a refresh token. The refresh token is valid only for the Google Account you signed\n into during the previous step.\n\n As part of this process, the script generates a URL and instructs you to\n visit the URL in a web browser.\n4. When the browser asks you to allow OAuth client access to Search Ads 360 data,\n make sure the Google Account you signed into earlier appears. (If you're signed into multiple\n Google Accounts, you might be presented with a different account.)\n\n\n At the end of the process, the `sa360Api.py` script outputs a comma-delimited\n string. The first value is the client ID you provided, the second value is the client\n secret you provided, and the third value is the refresh token. In the following example\n output, the refresh token is in **bold text** : \n\n `123456789123.apps.googleusercontent.com,ABCDEFGHIJKLMNOPQR_abcdef,`**1/HIJklM01OPQR23NOP456rst890uvw**\n5. Store the client ID, client secret, and refresh token in a backend database or other secure location that's accessible to your application.\n Keep the entire comma-delimited string in a convenient location if you plan to use\n `sa360Api.py` to send sample JSON requests to the Search Ads 360 API. You'll pass the\n entire string as a parameter each time you invoke the script.\n\n6. Add code to your application that does the following:\n 1. Use the client ID, client secret, and refresh token to obtain a fresh OAuth 2.0 access token.\n 2. Send requests to the Search Ads 360 API using the fresh access token.\n\n\n If you're using the client libraries, the next section, [Set Up Your Application](/search-ads/v2/configure),\n describes how to add this authorization code to your application.\n\n\n If you're not using one of the client libraries, see [Using OAuth 2.0 for Installed Applications](https://developers.google.com/accounts/docs/OAuth2InstalledApp) for\n suggestions on obtaining a fresh access token."]]