Closed MatthieuStigler closed 1 year ago
Hi @MatthieuStigler
rgee save the user credentials in subfolders inside .config/earthengine/
. The problem seems that the credentials you saved in the past are no longer valid. Therefore you need to delete the credentials because rgee will overwrite the new ones.
ee_clean_credentials("your_user")
ee_Initialize()
I'm in the middle of rewriting the auth of rgee, since now it has a lot of conflict with the latest versions of earthengine-api. the user argument will be deprecated.
thanks for your quick answer, will test tonight.
So if I understood you well, rgee is storing its own credentials elsewhere, then copying them to .config/earthengine/
? I assume this is also the folder where earthengine authenticate
stores the credentials? So this would explain why the new valid credentials are overwritten by the old one?
Thanks!
Yes exactly! I'm preparing a new rgee version without this weird behaviour. You can check the new auth in r-spatial/rgee@newauth
. I just checked the code below in the Rstudio cloud, and it works perfectly!
install.packages(c("remotes", "googledrive"))
remotes::install_github("r-spatial/rgee@newauth")
library(rgee)
ee_install()
# Run in a terminal ----------
# system("curl -sSL https://sdk.cloud.google.com | bash")
# PATH=$PATH:/home/rstudio-user/google-cloud-sdk/bin/
# earthengine authenticate --quiet
ee_Initialize(drive = TRUE)
I am having this issue around 1x per week now. The ee_clean_credentials()
work around does the trick, but is there a way to minimize having to do this?
Hi, @zackarno
We decided to change the default to auth_mode="notebook" (as geemap does) to avoid all the issues opened with gcloud no found (gcloud is the default in earthengine-api). I was very much against doing this because you only need to define the gcloud path in your $PATH. However, I think it can be a bit hard for new R/GoogleCloud users, so I decided to do it simply, and use auth_mode="notebook" (see: https://developers.google.com/earth-engine/apidocs/ee-authenticate)
The trade-off is that your credential will expire if I understand correctly (the documentation is not very clear here, I come to that conclusion based on my experience with GEE). I can think of two workarounds.
Option 1:
library(rgee)
ee_Authenticate(earthengine = TRUE, drive = FALSE, gcs = FALSE) # ask again for earthengine credentials
Option 2:
library(rgee)
# install and set gcloud on your computer and then
ee_Authenticate(earthengine = TRUE, auth_mode="gcloud") # None == 'gcloud' in local environments
# or simply
ee_Initialize(auth_mode="gcloud")
In theory, the credentials with gcloud shouldn't expire, but sometimes it does too (not sure but one day my credentials stop working after 5 moths, maybe I did something). Another option is to remove your credentials using ee_clean_user_credentials
.
I hope this has sense to you, let me know if you have an idea how to solve this issue with authentication. All these changes appeared after google applied more security to the initialization.
Hi @csaybar - thanks for the quick response and sorry for the delay getting back to you. That makes sense. I think I had been doing the initializing without specifying the auth_mode
and therefore not been using the gcloud
authentication. I had set up the gcloud and all seemed to be working fine so I was not aware of the auth_mode="notebook"
option even though I had been doing it by default. I just switched back to auth_mode="gcloud"
following your instructions under option 2 (thanks!!) so hopefully that should keep the credentials from expiring as frequently.
I've set up rgee on many computers and generally don't face major issues, but I have seen colleagues struggle and I believe gcloud could be one of the sticking points. These issues also tend to be relatively difficult to help trouble shoot remotely, so better understanding this notebook
vs gcloud
option seems really useful -- thank you very much!
I’m having a bit of a frustrating issue with the Google Earth Engine API. After initializing it successfully, I get this warning message: ✔ Initializing Google Earth Engine: DONE! credentials are cached in the path: C:\Users\dklmn/.config/earthengine/ Warning messages: 1: In ee_check_init() : Update your earthengine-api installations to v0.1.317 or greater. Earlier versions are not compatible with recent changes to the Earth Engine backend. 2: In ee_check_init() : Update your earthengine-api installations to v0.1.317 or greater. Earlier versions are not compatible with recent changes to the Earth Engine backend. Successfully saved authorization token. I already have earthengine-api version 1.1.1 installed.
ee_Initialize(auth_mode="gcloud") ── rgee 1.1.7 ──────────────────────────────────────────── earthengine-api 1.1.1 ── ✔ 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(). In addition: Warning messages: 1: In ee_check_init() : Update your earthengine-api installations to v0.1.317 or greater. Earlier versions are not compatible with recent changes to the Earth Engine backend. 2: In ee_check_init() : Update your earthengine-api installations to v0.1.317 or greater. Earlier versions are not compatible with recent changes to the Earth Engine backend.
I am authenticated to earthengine, but once I run
rgee::ee_Initialize(user =xxx')
, it seems to disconnect me, or de-authenticate me even on the command line?See below, where I am authenticated (i.e.
earthengine ls
returns something valid), I can runrgee::ee$Initialize()
and still get a validearthengine ls
, but once I runrgee::ee_Initialize(user =xxx')
it fails and then evenearthengine ls
fails?