ee.data.authenticateViaPrivateKey
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
הגדרת אימות בצד השרת של קריאות ל-EE API באמצעות Google APIs Node.js Client. אימות באמצעות מפתח פרטי מיועד אך ורק לקריאות 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 | בוליאני, אופציונלי | אם הערך הוא true, רק ההיקפים שצוינו ב-opt_extraScopes מבוקשים. ההיקפים שמוגדרים כברירת מחדל לא מבוקשים, אלא אם הם צוינו במפורש ב-opt_extraScopes. |
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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. |"]]