cloudyr / googleComputeEngineR

An R interface to the Google Cloud Compute API, for launching virtual machines
https://cloudyr.github.io/googleComputeEngineR/
Other
152 stars 41 forks source link

Error: gce_auth() is defunct #84

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hey Mark,

I am trying to launch RStudio Server with the help of googleComputeEngineR. But so far I can't authorize. My script codes looks like this: library(googleComputeEngineR)

library(googleComputeEngineR)
project <- "***"
zone <- "europe-west1-a"
account_key <- "***.json"
Sys.setenv(GCE_AUTH_FILE = account_key,
           GCE_DEFAULT_PROJECT_ID = project,
           GCE_DEFAULT_ZONE = zone)
gce_auth()

The issue I got is

Error: gce_auth() is defunct. Authenticate instead by downloading your JSON key and placing in a GCE_AUTH_FILE environment argument. See https://cloudyr.github.io/googleComputeEngineR/articles/installation-and-authentication.html or vignette('installation-and-authentication', package = 'googleComputeEngineR')

I've tried to create a .Renviron.txt file in project folder and put the gce_* attributes there, but still got the same problem.

sessionInfo() R version 3.4.1 (2017-06-30) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale: [1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251
[3] LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C
[5] LC_TIME=Russian_Russia.1251

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] googleComputeEngineR_0.2.0.9000

loaded via a namespace (and not attached): [1] googleAuthR_0.6.2.9000 httr_1.3.1 compiler_3.4.1 R6_2.2.2
[5] assertthat_0.2.0 parallel_3.4.1 tools_3.4.1 withr_2.1.0
[9] listenv_0.6.0 memoise_1.1.0 codetools_0.2-15 jsonlite_1.5
[13] digest_0.6.12 globals_0.10.3 devtools_1.13.4 future_1.6.2

I hope I could help with that,

Ruslan

MarkEdmondson1234 commented 6 years ago

You're almost there, the .Renviron.txt file should be called just .Renviron though. Rename it, start R and then you should be ok.

If that doesn't work, please paste the contents of that file too.

ghost commented 6 years ago

Oh yes, sorry for that. I fixed it, so now I get the following error:

2017-12-04 15:00:49> No environment argument found, looked in GCE_AUTH_FILE Set default project ID to '*' Set default zone to 'europe-west1-a'

Tried to enter full file location like "C:/R-proj/.../.json" and short one ".json" Also thought maybe there are some problems with that json file, so got new one, but still the same issue

UPDATE Alright, I fixed previous problem by renaming my .json file. It had "-" symbol, so I had to remove it. So now it looks like this:

library(googleComputeEngineR) Setting scopes to https://www.googleapis.com/auth/cloud-platform Successfully authenticated via test.json Set default project ID to 'test' Set default zone to 'europe-west1-a' gce_auth() Error: gce_auth() is defunct. Authenticate instead by downloading your JSON key and placing in a GCE_AUTH_FILE environment argument. See https://cloudyr.github.io/googleComputeEngineR/articles/installation-and-authentication.html or vignette('installation-and-authentication', package = 'googleComputeEngineR')

MarkEdmondson1234 commented 6 years ago

Can I see the contents of your .Renviron ? It also needs to be in the right place, easiest if using RStudio is to click on the "Home" breadcrumb link and put it there.

It should look something like this:

GCE_AUTH_FILE="C://location-of-json"
GCE_DEFAULT_PROJECT_ID="mark-xxxxxxx"
GCE_DEFAULT_ZONE="europe-west1-a"

It looks like the default project ID isn't being seen either.

ghost commented 6 years ago

.Renviron looks like this:

GCE_AUTH_FILE="test.json" GCE_DEFAULT_PROJECT_ID="test" GCE_DEFAULT_ZONE="europe-west1-a"

So, after removing "-" symbol from the .json file name authentification was completed (updated my last post), but the issues is still here

Error: gce_auth() is defunct

MarkEdmondson1234 commented 6 years ago

Oh, once you have that all done, you don't need to use gce_auth() at all - it is auto authenticated.

ghost commented 6 years ago

Oh, I see. Thank you so much for your time

So it is almost working now

Request failed [403]. Retrying in 1 seconds... Request failed [403]. Retrying in 3.2 seconds... 2017-12-04 16:09:55> Request Status Code: 403 Scopes: https://www.googleapis.com/auth/cloud-platform Method: service_json Error: API returned: Required 'compute.projects.get' permission for 'projects/test'

MarkEdmondson1234 commented 6 years ago

The "test" needs to be a valid google project id, you can use the same one that you downloaded the with file from.

MarkEdmondson1234 commented 6 years ago

Think this is sorted now?