praneeth kandula
praneeth kandula

Reputation: 114

Unable to Authenticate googleCloudStorageR/googleAuthR

I am trying to authenticate gcs in R using googleCloudStorageR and googleAuthR.

I have all the necessary APIs enabled on gcp.

I am able to authenticate with bigrquery when i run query_exec(sql,project,use_legacy_sql = FALSE), the browser opens up, the token is cached and everything works fine.

But when i try to do the same with googlecloudstorageR gcs_auth() or gar_auth() with googleAuthR. I keep getting the following error.

Error: option('googleAuthR.client_id') has not been set

I do not right now have permissions to create credentials from the API page. But i do not understand why i can auth bigrquery without having to do any of this but not googlecloudstorage through gcs_auth or gar_auth.

Also can i use the same client id and secret from the bigrquery .httr/oauth file to auth googlecloudstorage by changing the scope ?

Edit: I am using it at work, so i do not have privileges to create credentials from the https://console.cloud.google.com/apis/credentials page.

Code:

library(bigrquery)

project <- "mtproject"
sql <- "SELECT * FROM `myproject.Superstore.orders`"
data <- query_exec(sql,myproject,use_legacy_sql = FALSE)

When i run the above code, the browser opens up and gives me a token which i then copy and paste into R.

But when i try to authenticate using the following code for googleAuthR, nothing happens and i get the error.

library(googleAuthR)
2019-05-21 14:10:34> No environment argument found, looked in GAR_AUTH_FILE
Warning message:
package ‘googleAuthR’ was built under R version 3.5.3 
> gar_auth(new_user=TRUE)
Error: option('googleAuthR.client_id') has not been set

I did not set any client id for bigquery auth but that works, why is gar_auth not working ?

Upvotes: 1

Views: 938

Answers (1)

Ricardo
Ricardo

Reputation: 166

The option"googleAuthR.client_id" and "googleAuthR.client_secret" are changed by loading another library or setting them in a script, and then a cache file is used with different options set.

If you are always going to use the same credentials, make use of the auto authentication options by creating a cache token, moving it to a dedicated auth folder and using environment variables GAR_AUTH or package supported ones.

You can get more info in the following link: https://code.markedmondson.me/googleAuthR/articles/troubleshooting.html

Upvotes: 1

Related Questions