r-spatial / rgee

Google Earth Engine for R
https://r-spatial.github.io/rgee/
Other
691 stars 148 forks source link

Credential from Google Cloud SDK not working (and disappearing?) #357

Open carsontelford opened 9 months ago

carsontelford commented 9 months ago

At submit an issue, please attached the following information of your rgee session:

C:\Users\carso>earthengine -h usage: earthengine [-h] [--ee_config EE_CONFIG] [--service_account_file SERVICE_ACCOUNT_FILE] [--project PROJECT_OVERRIDE] {authenticate,acl,asset,cp,create,ls,alpha,du,mv,model,rm,set_project,task,unset_project,upload,upload_manifest,upload_table_manifest} ...

Earth Engine Command Line Interface.

options: -h, --help show this help message and exit --ee_config EE_CONFIG Path to the earthengine configuration file. Defaults to "~/.config\earthengine\credentials". --service_account_file SERVICE_ACCOUNT_FILE Path to a service account credentialsfile. Overrides any ee_config if specified. --project PROJECT_OVERRIDE Specifies a Google Cloud Platform Project id to override the call.

Commands: {authenticate,acl,asset,cp,create,ls,alpha,du,mv,model,rm,set_project,task,unset_project,upload,upload_manifest,upload_table_manifest} authenticate Prompts the user to authorize access to Earth Engine via OAuth2. acl Prints or updates the access control list of the specified asset. asset Prints or updates metadata associated with an Earth Engine asset. cp Creates a new Earth Engine asset as a copy of another asset. create Creates assets and folders. ls Prints the contents of a folder or collection. alpha Commands that are part of the v1alpha API. du Prints the size and names of all items in a given folder or collection. mv Moves or renames an Earth Engine asset. model TensorFlow model related commands. rm Deletes the specified assets. set_project Sets the default user project to be used for all API calls. task Prints information about or manages long-running tasks. unset_project UnSets the default user project to be used for all API calls. upload Uploads assets to Earth Engine. upload_manifest Uploads an image to Earth Engine using the given manifest file. upload_table_manifest Uploads a table to Earth Engine using the given manifest file.


- [ ] You can find the credentials file on your system: NO
```r
library(rgee)
ee_path <- path.expand("~/.config/earthengine/credentials")
file.exists(ee_path)
library(reticulate)
py_config()

py_config() python: C:/Users/carso/AppData/Local/r-miniconda/python.exe libpython: C:/Users/carso/AppData/Local/r-miniconda/python311.dll pythonhome: C:/Users/carso/AppData/Local/r-miniconda version: 3.11.4 | packaged by Anaconda, Inc. | (main, Jul 5 2023, 13:47:18) [MSC v.1916 64 bit (AMD64)] Architecture: 64bit numpy: C:/Users/carso/AppData/Local/r-miniconda/Lib/site-packages/numpy numpy_version: 1.26.4 ee: C:\Users\carso\AppData\Local\R-MINI~1\Lib\site-packages\ee

NOTE: Python version was forced by RETICULATE_PYTHON_FALLBACK

Description

I have been using RGEE for months but got the error that my credential had expired. I cleaned credentials and authenticated, getting the token from google, but it still didn't work. I deleted miniconda and reinstalled with the ee_install() function. After reinstalling numpy and google api through the command prompt ee_check() tells me my python version and packages look good. But when I run ee_initialize() I get the error that my EE credential is expired. I run ee_clean_user_credentials() followed by ee_Initialize() again and it doesn't fix it. I run ee_Authenticate() and am given a path that the credentials are saved, but ee_Initialize still doesn't work. Then I went to the command prompt and forced reauthentication with "earthengine authenticate --force". This directs me to login to gcloud SDK and I login and am notified that I have been authenticated. ee_Initialize then gives me the same error as before. I checked the path that ee_Authenticate gave me where my credentials are cached "credentials are cached in the path: C:\Users\carso/.config/earthengine/" but nothing there. I noticed when I force authenticate again in the command prompt, a credential file did appear. But then when I run ee_Authenticate the credential file disappears! At this point I do not know what else I can try. Do you have any ideas how I can resolve this issue?

Below I am copying the log information from all of the code I ran and the log output:

library(rgee) library(reticulate) R.version$version [1] "R version 4.3.1 (2023-06-16 ucrt)" packageVersion("rgee") [1] ‘1.1.6.9999’ Sys.info() sysname release version nodename machine login "Windows" "10 x64" "build 22621" "CTELFORD" "x86-64" "carso" user effective_user "carso" "carso" py_config() python: C:/Users/carso/AppData/Local/r-miniconda/python.exe libpython: C:/Users/carso/AppData/Local/r-miniconda/python311.dll pythonhome: C:/Users/carso/AppData/Local/r-miniconda version: 3.11.4 | packaged by Anaconda, Inc. | (main, Jul 5 2023, 13:47:18) [MSC v.1916 64 bit (AMD64)] Architecture: 64bit numpy: C:/Users/carso/AppData/Local/r-miniconda/Lib/site-packages/numpy numpy_version: 1.26.4 ee: C:\Users\carso\AppData\Local\R-MINI~1\Lib\site-packages\ee

NOTE: Python version was forced by RETICULATE_PYTHON_FALLBACK

earthengine_python <- Sys.getenv("EARTHENGINE_PYTHON", unset = NA) print(earthengine_python) [1] "C:\Users\carso\AppData\Local\r-miniconda\envs\rgee/python.exe" Sys.setenv(RETICULATE_PYTHON = earthengine_python)

if you run ee_check before this line it will break apparently, so dont do it.

ee_Initialize() ── rgee 1.1.6.9999 ───────────────────────────────────────────────── earthengine-api 0.1.391 ── ✔ user: not_defined ✔ Initializing Google Earth Engine: DONE! Error in value[3L] : It looks like your EE credential has expired. Try running ee_Authenticate() again or clean your credentials ee_clean_user_credentials(). ee_clean_user_credentials() ee_Initialize() ── rgee 1.1.6.9999 ───────────────────────────────────────────────── earthengine-api 0.1.391 ── ✔ user: not_defined ✔ Initializing Google Earth Engine: DONE! Error in value[3L] : It looks like your EE credential has expired. Try running ee_Authenticate() again or clean your credentials ee_clean_user_credentials(). ee_Authenticate() ✔ Initializing Google Earth Engine: DONE! credentials are cached in the path: C:\Users\carso/.config/earthengine/ ee_users() user EE GD GCS

carsontelford@gmail.com ✖ ✖ ✖

ee_check() ◉ Python version ✔ [Ok] C:/Users/carso/AppData/Local/r-miniconda/envs/rgee/python.exe v3.8 ◉ Python packages: ✔ [Ok] numpy ✔ [Ok] earthengine-api NOTE: The Earth Engine Python API version 0.1.391 is installed correctly in the system but rgee was tested using the version 0.1.360. To avoid possible issues, we recommend install the version used by rgee (0.1.360). You might use:

  • rgee::ee_install_upgrade()
  • reticulate::py_install('earthengine-api==0.1.360', envname='PUT_HERE_YOUR_PYENV')
  • pip install earthengine-api==0.1.360 (Linux and Mac0S)
  • conda install earthengine-api==0.1.360 (Linux, Mac0S, and Windows)

ee_path <- path.expand("~/.config/earthengine/credentials") file.exists(ee_path) [1] FALSE

mvdv01 commented 9 months ago

This issue is the same as issue #355 and so far it seems there's no joy in resolving this. I tried the same workaround as @jdbcode suggested, which gave some access to rgee basic functionality but am unable to access ImageCollections or Images - ee_print() or Map$addLayer() just produces nothing...

Thanks @csaybar and development team for all your efforts on rgee - I hope there can be some way to revive this package.