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 | بولی، اختیاری | وقتی درست است، فقط دامنه های مشخص شده در opt_extraScopes درخواست می شوند. دامنه های پیش فرض درخواست نمی شوند مگر اینکه به صراحت در opt_extraScopes مشخص شده باشند. |
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\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. |"]]