Google Earth Engine (GEE) allows users to create apps by three different approaches: user tokens, service accounts and client-side authentication. In this tutorial, we will get focus on the first option.
An EEtk is a 100-character text string (OAuth2 credential) stored on your local system that is used to identify and authenticate users (See Figure below). In other words, it will permit to connect the EE Web REST API with their local system.
In rgee the authentication procedure is triggered internally by ee_Initialize. This function will search for the ‘credentials’ file (it stores the EEtk) on the path: ~/.config/earthengine/.
library(rgee)
sprintf("%s/credentials", dirname(rgee::ee_get_earthengine_path()))
If the file exists, then an Oauth2 Credential object is created using a refresh token grant. This refresh token must come from a Google account registered in GEE if not a Bad Request error will be invoked. Once the Oauth2 Credential is successfully loaded, it is dynamically passed to all EE methods (See Initialize) in order to realize independent calls to the Web REST API. As you realize, the credentials file is crucial to interact with the EE API and if it does not exist on your system, it will simply not be possible to use rgee.
Deploying a rgee application can be a bit tricky, as you must perform the following task:
The first step is automatically accomplished for shinyapps.io. On the other hand, the second and third steps need to configure manually the virtual machine. To make the process straightforward we create shiny_rgee template.