R Googlsheets: Unable to use `gs_auth()` in google

2020-01-29 09:03发布

问题:

I am unable to authenticate my googlesheets package. Everytime I run the gs_auth() command I am taken to the chrome where I would usually login to enable the package to access my googlesheets:

However, lately every time I do this I have the following error from Google:

Here my session information:

sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS/LAPACK: /usr/lib/libopenblasp-r0.2.19.so

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

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

other attached packages:
[1] googlesheets_0.3.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2        crayon_1.3.4      dplyr_0.8.3       withr_2.1.2       assertthat_0.2.1  cellranger_1.1.0  R6_2.4.0         
 [8] magrittr_1.5      httr_1.4.1        pillar_1.4.2      rlang_0.4.1       cli_1.1.0         curl_4.2          renv_0.8.2-12    
[15] rstudioapi_0.10   tools_3.6.1       glue_1.3.1        purrr_0.3.3       compiler_3.6.1    askpass_1.1       pkgconfig_2.0.3  
[22] sessioninfo_1.1.1 openssl_1.4.1     tidyselect_0.2.5  tibble_2.1.3     

gs_auth()

I have also followed the instructions given here on this stack overflow question. However still no luck.

I have been able to access my sheet using the googledrive package, however I'd still like to fix this.

Thanks!

回答1:

googlesheets4 will replace googlesheets package very soon (by March 2020). Most of the functions performed by googlesheets can be handled by googlesheets4 currently, except for writing to specific cells.

googlesheets4 has a oauth authentication using Gargle (similar to googledrive package). More info can be found here - https://github.com/tidyverse/googlesheets4



回答2:

Adding the answer from Jenny Bryan (maintainer of googlesheets and googlesheets4) from Github to this issue here:

"Default oauth app not working any more" https://github.com/jennybc/googlesheets/issues/397

The link includes pretty detailed, step-by-step instructions, and I won't repeat what's she's already laid out really well. But quick version is you'll need to set up your own API credentials to make the oAuth client work. And remember, that will only help until March 2020.

Probably better, as @Kannan and others point out, is to make the switch to the new googlesheets4 package now if you can.