โฟลว์บัญชีบริการ OAuth
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
คู่มือนี้จะแนะนำวิธีตั้งค่า OAuth2 สำหรับการเข้าถึง API โดยใช้ข้อมูลเข้าสู่ระบบของคุณเองโดยใช้บัญชีบริการ
คุณต้องทำตามขั้นตอนเหล่านี้เพียงครั้งเดียว เว้นแต่จะเพิกถอนหรือลบข้อมูลเข้าสู่ระบบ OAuth2
สร้างข้อมูลเข้าสู่ระบบ OAuth2
สร้างรหัสบัญชีบริการและไฟล์ *.JSON โดย
ทำตามวิธีการที่ลิงก์ไว้ แล้วกลับมาที่หน้านี้
ตั้งค่าไลบรารีของไคลเอ็นต์
ตั้งค่าเส้นทาง JSON ของคีย์ส่วนตัวในการกำหนดค่า หากตรวจสอบสิทธิ์
โดยใช้การแอบอ้างเป็นบุคคลอื่น ให้ตั้งค่า
ผู้ใช้ที่จะแอบอ้างเป็นบุคคลอื่นด้วย
หากคุณใช้ไฟล์ ads.properties
ให้เพิ่มข้อมูลต่อไปนี้
api.googleads.serviceAccountSecretsPath=PRIVATE_KEY_FILE_PATH
# Only add this key if you are using impersonation.
api.googleads.serviceAccountUser=USER_TO_IMPERSONATE
ดูรายละเอียดเพิ่มเติมได้ที่คู่มือการกำหนดค่า
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-27 UTC
[null,null,["อัปเดตล่าสุด 2025-08-27 UTC"],[[["\u003cp\u003eThis guide explains how to set up OAuth2 for API access using service accounts with your own credentials.\u003c/p\u003e\n"],["\u003cp\u003eThe setup process involves generating a service account ID and a JSON file, and then configuring your client library with the necessary credentials.\u003c/p\u003e\n"],["\u003cp\u003eThis setup needs to be done only once and requires a Google Workspace domain with domain-wide delegation access granted to the service account.\u003c/p\u003e\n"]]],[],null,["# OAuth Service Account Flow\n\nThis guide will walk you through how to setup OAuth2 for API access using your\nown credentials using [service accounts](/google-ads/api/docs/oauth/service-accounts).\nThese steps only need to be done once, unless you revoke or delete your OAuth2\ncredentials.\n\nCreate OAuth2 credentials\n-------------------------\n\n[Generate a **service account ID and a \\*.JSON\nfile**](/google-ads/api/docs/oauth/service-accounts#service_account_access_setup) by\nfollowing the linked instructions, then come back to this page.\n\nSet up client library\n---------------------\n\nSet the private key JSON path in your configuration. If you're [authenticating\nusing impersonation](/google-ads/api/docs/oauth/service-accounts#impersonation), also set the\nuser to impersonate.\n\nIf you're using an `ads.properties` file, add the following: \n\n api.googleads.serviceAccountSecretsPath=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-s\"\u003ePRIVATE_KEY_FILE_PATH\u003c/span\u003e\u003c/var\u003e\n # Only add this key if you are using impersonation.\n api.googleads.serviceAccountUser=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-s\"\u003eUSER_TO_IMPERSONATE\u003c/span\u003e\u003c/var\u003e\n\nSee the [configuration guide](/google-ads/api/docs/client-libs/java/config-file) for\nadditional details."]]