ee.data.authenticateViaPrivateKey
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
กำหนดค่าการตรวจสอบสิทธิ์ฝั่งเซิร์ฟเวอร์ของการเรียก EE API ผ่านไคลเอ็นต์ Google APIs Node.js การตรวจสอบสิทธิ์ด้วยคีย์ส่วนตัวใช้สำหรับการเรียก API ฝั่งเซิร์ฟเวอร์เท่านั้น สำหรับแอปพลิเคชันที่ใช้เบราว์เซอร์ ให้ใช้ ee.data.authenticateViaOauth() ไม่จำเป็นต้องมีการโต้ตอบจากผู้ใช้ (เช่น ป๊อปอัปการตรวจสอบสิทธิ์) เมื่อใช้การตรวจสอบสิทธิ์ฝั่งเซิร์ฟเวอร์
ควรกำหนดวิธีการตรวจสอบสิทธิ์นี้หรือวิธีการอื่นก่อนเรียกใช้ ee.initialize()
ระบบจะรีเฟรชโทเค็นการให้สิทธิ์โดยอัตโนมัติเมื่อเป็นไปได้ คุณสามารถมั่นใจได้ว่าระบบจะส่งการเรียกแบบไม่พร้อมกันทั้งหมดพร้อมกับข้อมูลเข้าสู่ระบบที่เหมาะสม อย่างไรก็ตาม สำหรับการเรียกแบบซิงโครนัส คุณควรตรวจสอบโทเค็นการให้สิทธิ์ด้วย ee.data.getAuthToken() และเรียกใช้ ee.data.refreshAuthToken() ด้วยตนเองหากไม่มี การดำเนินการรีเฟรชโทเค็นเป็นแบบอะซิงโครนัสและไม่สามารถดำเนินการเบื้องหลังตามคำขอได้ก่อนการเรียกแบบซิงโครนัส
การใช้งาน | การคืนสินค้า |
---|
ee.data.authenticateViaPrivateKey(privateKey, success, error, extraScopes, suppressDefaultScopes) | |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
privateKey | AuthPrivateKey | เนื้อหา JSON ของคีย์ส่วนตัว |
success | ฟังก์ชัน (ไม่บังคับ) | ฟังก์ชันที่จะเรียกใช้หากการตรวจสอบสิทธิ์สำเร็จ |
error | ฟังก์ชัน (ไม่บังคับ) | ฟังก์ชันที่จะเรียกใช้หากการตรวจสอบสิทธิ์ไม่สำเร็จ โดยส่งข้อความแสดงข้อผิดพลาด |
extraScopes | List<String> ไม่บังคับ | ขอบเขต OAuth เพิ่มเติมที่จะขอ |
suppressDefaultScopes | บูลีน ไม่บังคับ | เมื่อเป็นจริง ระบบจะขอเฉพาะขอบเขตที่ระบุใน opt_extraScopes เท่านั้น และจะไม่ขอขอบเขตเริ่มต้น เว้นแต่จะระบุอย่างชัดเจนใน opt_extraScopes |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eEnables server-side authentication for Earth Engine API calls using a private key, suitable for non-browser environments.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication happens automatically for asynchronous calls, but synchronous calls require manual token checks and refresh using \u003ccode\u003eee.data.getAuthToken()\u003c/code\u003e and \u003ccode\u003eee.data.refreshAuthToken()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eee.data.authenticateViaPrivateKey()\u003c/code\u003e function facilitates this authentication process, accepting the private key and optional success/error callbacks, extra scopes, and a flag to suppress default scopes.\u003c/p\u003e\n"]]],[],null,["# ee.data.authenticateViaPrivateKey\n\n\u003cbr /\u003e\n\nConfigures server-side authentication of EE API calls through the Google APIs Node.js Client. Private key authentication is strictly for server-side API calls: for browser-based applications, use ee.data.authenticateViaOauth(). No user interaction (e.g. authentication popup) is necessary when using server-side authentication.\n\n\u003cbr /\u003e\n\nThis or another authentication method should be called before ee.initialize().\n\nThe auth token will be refreshed automatically when possible. You can safely assume that all async calls will be sent with the appropriate credentials. For synchronous calls, however, you should check for an auth token with ee.data.getAuthToken() and call ee.data.refreshAuthToken() manually if there is none. The token refresh operation is asynchronous and cannot be performed behind-the-scenes, on demand, prior to synchronous calls.\n\n| Usage | Returns |\n|------------------------------------------------------------------------------------------------------------------------|---------|\n| `ee.data.authenticateViaPrivateKey(privateKey, `*success* `, `*error* `, `*extraScopes* `, `*suppressDefaultScopes*`)` | |\n\n| Argument | Type | Details |\n|-------------------------|--------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `privateKey` | AuthPrivateKey | JSON content of private key. |\n| `success` | Function, optional | The function to call if authentication succeeded. |\n| `error` | Function, optional | The function to call if authentication failed, passed the error message. |\n| `extraScopes` | List\\\u003cString\\\u003e, optional | Extra OAuth scopes to request. |\n| `suppressDefaultScopes` | Boolean, optional | When true, only scopes specified in opt_extraScopes are requested; the default scopes are not not requested unless explicitly specified in opt_extraScopes. |"]]