ตั้งค่าการให้สิทธิ์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Search Ads 360 API กําหนดให้คําขอทั้งหมดระบุโทเค็นการเข้าถึง OAuth 2.0 เพื่อตรวจสอบสิทธิ์ คุณทําตามเวิร์กโฟลว์การตรวจสอบสิทธิ์ OAuth 2.0 มาตรฐานเพื่อสร้างโทเค็นและส่งไปยัง Search Ads 360 API ได้ เราแนะนําให้ใช้เวิร์กโฟลว์ที่อธิบายด้านล่าง เนื่องจากเหมาะสำหรับการอัปโหลด Conversion แบบอัตโนมัติเต็มรูปแบบและการดาวน์โหลดรายงาน
ดูทางเลือกอื่นสำหรับเวิร์กโฟลว์ที่อธิบายไว้ด้านล่างได้ที่การใช้ OAuth 2.0 สําหรับแอปพลิเคชันที่ติดตั้ง หรือ
การใช้ OAuth 2.0 สําหรับแอปพลิเคชันที่มีการโต้ตอบระหว่างเซิร์ฟเวอร์กับเซิร์ฟเวอร์ หากคุณใช้เวิร์กโฟลว์อื่น ให้ระบุค่าต่อไปนี้เป็นพารามิเตอร์ scope
เมื่อขอรหัสการให้สิทธิ์ OAuth 2.0
https://www.googleapis.com/auth/doubleclicksearch
หากใช้เส้นทางแบบเซิร์ฟเวอร์ต่อเซิร์ฟเวอร์ ให้เพิ่มบัญชีบริการเป็นผู้ใช้ Search Ads 360
เวิร์กโฟลว์การให้สิทธิ์ที่แนะนำ
- ไปที่คอนโซล Google API แล้วเลือกโปรเจ็กต์
หากยังไม่ได้สร้างโปรเจ็กต์คอนโซล Google API และข้อมูลเข้าสู่ระบบ OAuth ให้ทำตามวิธีการในสร้างโปรเจ็กต์คอนโซล Google API และข้อมูลเข้าสู่ระบบ OAuth สำหรับไคลเอ็นต์
หากต้องการค้นหารหัสและรหัสลับไคลเอ็นต์ OAuth ของโปรเจ็กต์ ให้ทําดังนี้
- เปิดหน้าข้อมูลเข้าสู่ระบบ
- ในคอลัมน์ชื่อ ให้คลิกชื่อไคลเอ็นต์ OAuth
- รหัสและรหัสลับไคลเอ็นต์จะแสดงอยู่ในหน้าดังกล่าว
- เปิดเว็บเบราว์เซอร์ แล้วลงชื่อเข้าใช้ Google
ด้วยบัญชี Google ที่มีสิทธิ์เข้าถึงข้อมูลใน Search Ads 360
นี่คือบัญชี 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
จะแสดงผลสตริงที่คั่นด้วยคอมมา ค่าแรกคือรหัสไคลเอ็นต์ที่คุณระบุ ค่าที่ 2 คือรหัสลับไคลเอ็นต์ที่คุณระบุ และค่าที่ 3 คือโทเค็นรีเฟรช ในตัวอย่างเอาต์พุตต่อไปนี้ โทเค็นรีเฟรชจะอยู่ในข้อความตัวหนา
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 สําหรับแอปพลิเคชันที่ติดตั้ง
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-11-07 UTC
[null,null,["อัปเดตล่าสุด 2024-11-07 UTC"],[[["\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."]]