MarkEdmondson1234 / searchConsoleR

R interface with Google Search Console API v3, including Search Analytics.
http://code.markedmondson.me/searchConsoleR/
Other
114 stars 41 forks source link

Auth on a R Server #57

Closed DavidGarciaEstaun closed 4 years ago

DavidGarciaEstaun commented 4 years ago

What goes wrong

Hi Mark,

I need to auth on a R Server using an auto-authentication auth. I am following the help of scr_auth function. I set up the service account json path with the SC_AUTH_FILE variable via the Sys.setenv() function but I am receiving this error:

Error: Not authenticated. Run scr_auth()

In other of your librarys like googleCloudStorageR you can set the service account json_file setting a parameter "json_file" on the auth function. Ex: gcs_auth(json_file="/zzzz/ddfdd/ggg.json"). What can I do to auth in searchConsoleR?

Thanks for your help. :)

Expected output

A normal auth

Actual output

Error: Not authenticated. Run scr_auth()

Session Info

R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.4 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1 LAPACK: /usr/local/lib/R/lib/libRlapack.so

Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] googleAuthR_1.1.1 stringr_1.4.0 lubridate_1.7.4 dplyr_0.8.5
[5] searchConsoleR_0.4.0

loaded via a namespace (and not attached): [1] Rcpp_1.0.4 crayon_1.3.4 digest_0.6.25 assertthat_0.2.1 R6_2.4.1
[6] jsonlite_1.6.1 magrittr_1.5 pillar_1.4.3 httr_1.4.1 stringi_1.4.6
[11] rlang_0.4.5 rstudioapi_0.11 fs_1.3.2 tools_3.6.2 glue_1.3.2
[16] purrr_0.3.3 compiler_3.6.2 pkgconfig_2.0.3 gargle_0.4.0 memoise_1.1.0
[21] tidyselect_1.0.0 tibble_2.1.3

MarkEdmondson1234 commented 4 years ago

You can do the same, but a bit more manually by using googleAuthR::gar_auth_service() - then add the service email as a user to Search Console.

DavidGarciaEstaun commented 4 years ago

I have added the service account json file as a parameter of the function and works perfectly. Thank you so much Mark! :)