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.

What is an EE user token (EEtk)?

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/.

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.

Please never show or share your token with anyone, it will give full access to all your Earth Engine resources.

Deploying a simple rgee shiny app on

Deploying a rgee application can be a bit tricky, as you must perform the following task:

  1. Install R packages.
  2. Install Python and third-party packages.
  3. Set the credentials file in the path ~/.config/earthengine/.

The first step is automatically accomplished for 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.