ee.data.authenticateViaPrivateKey
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Konfiguruje uwierzytelnianie wywołań interfejsu EE API po stronie serwera za pomocą klienta Google API Node.js. Uwierzytelnianie za pomocą klucza prywatnego jest przeznaczone wyłącznie dla wywołań interfejsu API po stronie serwera.W przypadku aplikacji działających w przeglądarce użyj funkcji ee.data.authenticateViaOauth(). Podczas uwierzytelniania po stronie serwera nie jest wymagana interakcja z użytkownikiem (np. wyskakujące okienko uwierzytelniania).
Tę lub inną metodę uwierzytelniania należy wywołać przed ee.initialize().
Token uwierzytelniający będzie w miarę możliwości odświeżany automatycznie. Możesz bezpiecznie założyć, że wszystkie wywołania asynchroniczne będą wysyłane z odpowiednimi danymi logowania. W przypadku wywołań synchronicznych sprawdź jednak, czy jest dostępny token uwierzytelniania, używając funkcji ee.data.getAuthToken(), a jeśli go nie ma, wywołaj ręcznie funkcję ee.data.refreshAuthToken(). Odświeżanie tokena jest operacją asynchroniczną i nie można jej wykonać w tle, na żądanie, przed wywołaniami synchronicznymi.
Wykorzystanie | Zwroty |
---|
ee.data.authenticateViaPrivateKey(privateKey, success, error, extraScopes, suppressDefaultScopes) | |
Argument | Typ | Szczegóły |
---|
privateKey | AuthPrivateKey | Treść JSON klucza prywatnego. |
success | Funkcja (opcjonalnie) | Funkcja, która ma zostać wywołana, jeśli uwierzytelnianie się powiedzie. |
error | Funkcja (opcjonalnie) | Funkcja, którą należy wywołać w przypadku nieudanego uwierzytelniania, przekazała komunikat o błędzie. |
extraScopes | List<String>, opcjonalnie | Dodatkowe zakresy protokołu OAuth, o które chcesz poprosić. |
suppressDefaultScopes | Wartość logiczna, opcjonalna | Jeśli ma wartość „true”, żądane są tylko zakresy określone w parametrze opt_extraScopes. Zakresy domyślne nie są żądane, chyba że zostały wyraźnie określone w parametrze opt_extraScopes. |
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 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. |"]]