AI-generated Key Takeaways
-
Private key authentication is for server-side API calls and requires no user interaction.
-
This authentication method must be called before
ee.initialize()
. -
Auth tokens refresh automatically for asynchronous calls, but synchronous calls may require manual token checks and refreshing.
-
The
ee.data.authenticateViaPrivateKey
function is used, taking the private key JSON and optional success, error, extraScopes, and suppressDefaultScopes arguments.
This or another authentication method should be called before ee.initialize().
The 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.
Usage | Returns |
---|---|
ee.data.authenticateViaPrivateKey(privateKey, success, error, extraScopes, suppressDefaultScopes) |
Argument | Type | Details |
---|---|---|
privateKey | AuthPrivateKey | JSON content of private key. |
success | Function, optional | The function to call if authentication succeeded. |
error | Function, optional | The function to call if authentication failed, passed the error message. |
extraScopes | List<String>, optional | Extra OAuth scopes to request. |
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. |