MarkEdmondson1234 / googleAuthR

Google API Client Library for R. Easy authentication and help to build Google API R libraries with OAuth2. Shiny compatible.
https://code.markedmondson.me/googleAuthR
Other
175 stars 54 forks source link

Failed to authenticate using the JSON file #187

Closed Martijn012 closed 3 years ago

Martijn012 commented 4 years ago

Hi Mark,

I'm trying to use the package in order to set up cloud computing services of Google on Rstudio. However, I keep getting the same error when I try to authenticate using the JSON file.

This is my code:

library(googleComputeEngineR)

and this is the output:

Setting scopes to https://www.googleapis.com/auth/cloud-platform
Failed! Auto-authentication via GCE_AUTH_FILE=/Users/Martijn/Downloads/auth_key3.json - error was: cannot open the connection
Set default project ID to 'rstudio-XXX'
Set default zone to 'us-central1-c'
Warning message:
In open.connection(con, "rb") :
  cannot open file '/Users/Martijn/Downloads/auth_key3.json': Operation not permitted

My .Renviron looks like this:

GCE_AUTH_FILE="/Users/Martijn/Downloads/auth_key3.json"
GCE_DEFAULT_PROJECT_ID="rstudio-XXX"
GCE_DEFAULT_ZONE="us-central1-c"

I think the problem is caused by something inside the GCE console, but I cannot determine what it is. Hopefully anybody can assist me with this matter

MarkEdmondson1234 commented 4 years ago

It looks like it's all set up ok but the file can't be read from the error message - if you call file.exists(Sys.getenv("GCE_AUTH_FILE")) does it return true?

Double check the file path maybe? File permissions?