How to fix error “Can't get Google credentials” running from “crontab” for R package “bigrquery”?

There is a great R package "bigrquery". I can run the code below in RStudio and from the console. But it gives me an error "Can't get Google credentials" when I try to run it via "crontab".

Here is the code:

# 1. Library
library(bigrquery)

# 2. Credentials
BQ_AUTH_PATH <- "file_name.json"
BQ_PROJECT_ID <- "project_id"

# 3. Auth to BQ via 'json' credentials
bq_auth(path = BQ_AUTH_PATH)

# 4. Define 'project_id'
project_id <- BQ_PROJECT_ID

# 5. Define SQL queries
sql <- "SELECT * FROM `data_table`"

# 5. Load data
query_exec(sql, project_id, use_legacy_sql = FALSE)

Please, advise on how to fix this issue.

Thanks

I fixed this issue by adding Google email into "bq_auth" function call

BQ_AUTH_PATH <- "path_credentials_json"
BQ_AUTH_EMAIL <- "google_email"
bq_auth(path = BQ_AUTH_PATH, email = BQ_AUTH_EMAIL)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.