Closed mloehr09 closed 3 years ago
Strange if it was working before, but the error suggests the JSON file does not exist? Try adding a cat(jsonlite::fromJSON("gcs_key.json"))
to see if you get any output. I suspect the path to the file is incorrect.
It is for these kind of issues I recommend using the environment arguments for authentication, since they encourage absolute file paths.
Thank you for your quick feedback.
I found the reason why it didn't work. The script which creates the cron job was in the subfolder with the other scripts and not in the home folder of the VM.
Your suggestion to add cat(jsonlite::fromJSON("gcs_key.json"))
gave me the idea that this might be the reason. Many thanks and sorry for bothering you with this stuff though it had nothing to do with your package
What goes wrong
Hi Mark,
I use the most recent version of your package and since two weeks I get the error message "Error: lexical error: invalid char in json text." when I use a cronjob to run the script on a VM in the google cloud and also when I try to run it on Docker. When I run it "manually" everything works fine
Here you can find the first few rows of my script:
`library(googleAuthR) library(googleAnalyticsR) library(googlesheets4) library(googledrive) library(tidyverse)
options(googleAuthR.verbose=2)
sessionInfo()
gar_auth_service("gcs_key.json")`
and here you can find the message in the logfile:
`ℹ 2021-06-13 06:00:02 > No consent file found
Attaching package: ‘googledrive’
The following objects are masked from ‘package:googlesheets4’:
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ── ✔ ggplot2 3.3.3 ✔ purrr 0.3.4 ✔ tibble 3.1.0 ✔ dplyr 1.0.5 ✔ tidyr 1.1.3 ✔ stringr 1.4.0 ✔ readr 1.4.0 ✔ forcats 0.5.1 ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ── ✖ dplyr::filter() masks stats::filter() ✖ dplyr::lag() masks stats::lag() R version 4.0.5 (2021-03-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.2 LTS
Matrix products: default BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so
locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=C
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices utils datasets methods base
other attached packages: [1] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.5
[4] purrr_0.3.4 readr_1.4.0 tidyr_1.1.3
[7] tibble_3.1.0 ggplot2_3.3.3 tidyverse_1.3.0
[10] googledrive_1.0.1 googlesheets4_0.3.0 googleAnalyticsR_1.0.0 [13] googleAuthR_1.4.0
loaded via a namespace (and not attached): [1] tidyselect_1.1.0 haven_2.4.0
[3] gargle_1.1.0 colorspace_2.0-0
[5] vctrs_0.3.7 generics_0.1.0
[7] usethis_2.0.1 utf8_1.2.1
[9] rlang_0.4.10 pillar_1.6.0
[11] glue_1.4.2 withr_2.4.1
[13] DBI_1.1.1 rappdirs_0.3.3
[15] dbplyr_2.1.1 modelr_0.1.8
[17] readxl_1.3.1 lifecycle_1.0.0
[19] munsell_0.5.0 gtable_0.3.0
[21] cellranger_1.1.0 rvest_1.0.0
[23] measurementProtocol_0.1.0 memoise_2.0.0
[25] fastmap_1.1.0 ps_1.6.0
[27] fansi_0.4.2 broom_0.7.6
[29] Rcpp_1.0.6 backports_1.2.1
[31] scales_1.1.1 cachem_1.0.4
[33] jsonlite_1.7.2 fs_1.5.0
[35] hms_1.0.0 digest_0.6.27
[37] stringi_1.5.3 grid_4.0.5
[39] cli_2.4.0 tools_4.0.5
[41] magrittr_2.0.1 crayon_1.4.1
[43] whisker_0.4 pkgconfig_2.0.3
[45] ellipsis_0.3.1 xml2_1.3.2
[47] reprex_2.0.0 lubridate_1.7.10
[49] assertthat_0.2.1 httr_1.4.2
[51] rstudioapi_0.13 R6_2.5.0
[53] compiler_4.0.5
Error: lexical error: invalid char in json text. gcs_key.json (right here) ------^ Execution halted`
gcs_key.json is safed as a json file.
Unfortunately I have no idea where to start troubleshooting and would greatly appreciate your help.
Kind regards, Michael