r-spatial / rgee

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

Error 400 in Google after running ee_Initialize in Ubuntu #275

Closed gsaabogado closed 1 year ago

gsaabogado commented 2 years ago

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

library(rgee)

# Initialize the Earth Engine module.
ee_Initialize()

# Print metadata for a DEM dataset.
print(ee$Image('USGS/SRTMGL1_003')$getInfo())

Attach your Python (reticulate) configuration:

library(reticulate)
py_config()

python: /users_home/seme/ls01122/.local/share/r-miniconda/envs/r-reticulate/bin/python libpython: /users_home/seme/ls01122/.local/share/r-miniconda/envs/r-reticulate/lib/libpython3.8.so pythonhome: /users_home/seme/ls01122/.local/share/r-miniconda/envs/r-reticulate:/users_home/seme/ls01122/.local/share/r-miniconda/envs/r-reticulate version: 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:18) [GCC 10.3.0] numpy: /users_home/seme/ls01122/.local/share/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/numpy numpy_version: 1.23.1

Description

Describe what you were trying to get done. I am trying to run the ee_Initialize function for the first time Tell us what happened, what went wrong, and what you expected to happen. The function seems to work properly. However, the link it produces is invalid for google -- i.e., error 400 (Authorization error)

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

The command is

ee_Initialize()

The output is:

✔ user: not_defined ✔ Initializing Google Earth Engine:Fetching credentials using gcloud Go to the following link in your browser:

https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=517222506229-vsmmajv00ul0bs7p89v5m89qs8eb9359.apps.googleusercontent.com&redirect_uri=https%3A%2F%2Fsdk.cloud.google.com%2Fapplicationdefaultauthcode.html&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fearthengine+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdevstorage.full_control+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=4ZihU4ruElIlHPXkNY9g3kVSgWwdvL&prompt=consent&access_type=offline&code_challenge=KLvAe3IxfAMWqkNpxxb98R5mfOWV2yQqMQx_VQTo148&code_challenge_method=S256

Enter authorization code:

After selecting the link, I get the error 400 -- I attach the web-page with the error GoogleError

milesalanmoore commented 2 years ago

Do you have anaconda installed in addition to the miniconda used by rgee? I had a similar issue that was solved by exiting out of conda base by running (in bash/zsh) $ conda deactivate and then installing gcloud via brew install --cask google-cloud-sdk Although gcloud was installed in my terminal in both the base and an 'ee' named virtual env via anaconda, it wasn't in my bare terminal which is likely what library(reticulate) is using when it runs various commands via base::system() in your terminal to init and authenticate ee.

see #273 for context

csaybar commented 1 year ago

I think this has been solved in the latest version. Please open a new issue if you still need help. ee_Initialize(auth_quiet = TRUE, auth_mode = "gcloud"), check auth_mod documentation