tidyverse / googlesheets4

Google Spreadsheets R API (reboot of the googlesheets package)
https://googlesheets4.tidyverse.org
Other
360 stars 53 forks source link

Cannot use cached token on the updated version only (v0.3.0) #218

Closed CorradoLanera closed 3 years ago

CorradoLanera commented 3 years ago

Overview

After updating {googlesheets4} from v0.2.0 to v0.3.0 (and {gargle} from v0.5 to v1.0) cache seams not to be seen anymore.

Using {renv}, on the same machine at the "same" moment, everything still working with the old versions of the packages.

Reprex w/o {renv}

# renv::load("~/Documents/ubep/covid19.icuve/")

gargle::gargle_oauth_sitrep()
#> gargle OAuth cache path:
#> /home/cl/.R/gargle/gargle-oauth
#> 
#> 2 tokens found
#> 
#> email                  app                scopes                   hash...   
#> ______________________ __________________ ________________________ __________
#> dario.gregori@unipd.it tidyverse-calliope ...spreadsheets          6c91f3d...
#> dario.gregori@unipd.it tidyverse-calliope ...spreadsheets.readonly 9d7ec23...

googlesheets4::gs4_auth("dario.gregori@unipd.it")
#> Error: Can't get Google credentials.
#> Are you running googlesheets4 in a non-interactive session? Consider:
#>   * `gs4_deauth()` to prevent the attempt to get credentials.
#>   * Call `gs4_auth()` directly with all necessary specifics.
#> See gargle's "Non-interactive auth" vignette for more details:
#> https://gargle.r-lib.org/articles/non-interactive-auth.html

googlesheets4::gs4_user()
#> Not logged in as any specific Google user.

Created on 2021-03-07 by the reprex package (v1.0.0)

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.4 (2021-02-15) #> os Debian GNU/Linux bullseye/sid #> system x86_64, linux-gnu #> ui X11 #> language en_US:it #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Rome #> date 2021-03-07 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> askpass 1.1 2019-01-13 [1] CRAN (R 4.0.2) #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2) #> backports 1.2.1 2020-12-09 [1] RSPM (R 4.0.3) #> cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.0.2) #> cli 2.3.1 2021-02-23 [1] RSPM (R 4.0.4) #> crayon 1.4.1 2021-02-08 [1] RSPM (R 4.0.3) #> curl 4.3 2019-12-02 [1] RSPM (R 4.0.2) #> DBI 1.1.1 2021-01-15 [1] CRAN (R 4.0.3) #> debugme 1.1.0 2017-10-22 [1] RSPM (R 4.0.3) #> digest 0.6.27 2020-10-24 [1] RSPM (R 4.0.3) #> dplyr 1.0.5 2021-03-05 [1] CRAN (R 4.0.4) #> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.2) #> fansi 0.4.2 2021-01-15 [1] CRAN (R 4.0.3) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2) #> gargle 1.0.0 2021-03-03 [1] RSPM (R 4.0.4) #> generics 0.1.0 2020-10-31 [1] RSPM (R 4.0.3) #> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2) #> googledrive 1.0.1 2020-05-05 [1] RSPM (R 4.0.3) #> googlesheets4 0.3.0 2021-03-04 [1] RSPM (R 4.0.4) #> highr 0.8 2019-03-20 [1] CRAN (R 4.0.2) #> htmltools 0.5.1.1 2021-01-22 [1] RSPM (R 4.0.3) #> httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.2) #> jsonlite 1.7.2 2020-12-09 [1] RSPM (R 4.0.3) #> knitr 1.31 2021-01-27 [1] CRAN (R 4.0.3) #> lifecycle 1.0.0 2021-02-15 [1] RSPM (R 4.0.3) #> magrittr 2.0.1 2020-11-17 [1] RSPM (R 4.0.3) #> openssl 1.4.3 2020-09-18 [1] RSPM (R 4.0.3) #> pillar 1.5.1 2021-03-05 [1] CRAN (R 4.0.4) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.2) #> R6 2.5.0 2020-10-28 [1] RSPM (R 4.0.3) #> reprex 1.0.0 2021-01-27 [1] CRAN (R 4.0.3) #> rlang 0.4.10 2020-12-30 [1] CRAN (R 4.0.3) #> rmarkdown 2.7 2021-02-19 [1] RSPM (R 4.0.4) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2) #> stringi 1.5.3 2020-09-09 [1] RSPM (R 4.0.3) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.2) #> styler 1.3.2 2020-02-23 [1] CRAN (R 4.0.2) #> tibble 3.1.0 2021-02-25 [1] RSPM (R 4.0.4) #> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.2) #> utf8 1.1.4 2018-05-24 [1] CRAN (R 4.0.2) #> vctrs 0.3.6 2020-12-17 [1] RSPM (R 4.0.3) #> withr 2.4.1 2021-01-26 [1] RSPM (R 4.0.3) #> xfun 0.21 2021-02-10 [1] RSPM (R 4.0.3) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.2) #> #> [1] /home/cl/R/x86_64-pc-linux-gnu-library/4.0 #> [2] /usr/local/lib/R/site-library #> [3] /usr/lib/R/site-library #> [4] /usr/lib/R/library ```

Reprex w/ {renv}

renv::load("~/Documents/ubep/covid19.icuve/")

gargle::gargle_oauth_sitrep()
#> gargle OAuth cache path:
#> /home/cl/.R/gargle/gargle-oauth
#> 
#> 2 tokens found
#> 
#> email                  app                scopes                   hash...   
#> * ______________________ __________________ ________________________ __________
#> * dario.gregori@unipd.it tidyverse-calliope ...spreadsheets          6c91f3d...
#> * dario.gregori@unipd.it tidyverse-calliope ...spreadsheets.readonly 9d7ec23...

googlesheets4::gs4_auth("dario.gregori@unipd.it")

googlesheets4::gs4_user()
#> [1] "dario.gregori@unipd.it"

Created on 2021-03-07 by the reprex package (v1.0.0)

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.4 (2021-02-15) #> os Debian GNU/Linux bullseye/sid #> system x86_64, linux-gnu #> ui X11 #> language en_US:it #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Rome #> date 2021-03-07 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> ! package * version date lib source #> P askpass 1.1 2019-01-13 [?] CRAN (R 4.0.3) #> P assertthat 0.2.1 2019-03-21 [?] CRAN (R 4.0.3) #> VP backports 1.2.1 2020-11-02 [?] RSPM (R 4.0.3) #> P cellranger 1.1.0 2016-07-27 [?] CRAN (R 4.0.3) #> VP cli 2.3.1 2020-10-12 [?] CRAN (R 4.0.3) #> VP crayon 1.4.1 2017-09-16 [?] CRAN (R 4.0.3) #> P curl 4.3 2019-12-02 [?] CRAN (R 4.0.3) #> R debugme 1.1.0 [?] #> P digest 0.6.27 2020-10-24 [?] RSPM (R 4.0.3) #> P dplyr 1.0.2 2020-08-18 [?] CRAN (R 4.0.3) #> P ellipsis 0.3.1 2020-05-15 [?] CRAN (R 4.0.3) #> P evaluate 0.14 2019-05-28 [?] CRAN (R 4.0.3) #> VP fansi 0.4.2 2020-01-08 [?] CRAN (R 4.0.3) #> P fs 1.5.0 2020-07-31 [?] CRAN (R 4.0.3) #> P gargle 0.5.0 2020-05-06 [?] RSPM (R 4.0.3) #> generics 0.1.0 2020-10-31 [1] RSPM (R 4.0.3) #> P glue 1.4.2 2020-08-27 [?] CRAN (R 4.0.3) #> P googledrive 1.0.1 2020-05-05 [?] RSPM (R 4.0.3) #> P googlesheets4 0.2.0 2020-05-08 [?] RSPM (R 4.0.3) #> P highr 0.8 2019-03-20 [?] CRAN (R 4.0.3) #> VP htmltools 0.5.1.1 2020-06-16 [?] CRAN (R 4.0.3) #> P httr 1.4.2 2020-07-20 [?] CRAN (R 4.0.3) #> P jsonlite 1.7.1 2020-09-07 [?] CRAN (R 4.0.3) #> VP knitr 1.31 2020-09-22 [?] CRAN (R 4.0.3) #> VP lifecycle 1.0.0 2020-03-06 [?] CRAN (R 4.0.3) #> VP magrittr 2.0.1 2014-11-22 [?] CRAN (R 4.0.3) #> P openssl 1.4.3 2020-09-18 [?] CRAN (R 4.0.3) #> VP pillar 1.5.1 2020-07-10 [?] CRAN (R 4.0.3) #> P pkgconfig 2.0.3 2019-09-22 [?] CRAN (R 4.0.3) #> P purrr 0.3.4 2020-04-17 [?] CRAN (R 4.0.3) #> R6 2.5.0 2020-10-28 [1] RSPM (R 4.0.3) #> VP renv 0.13.0 2020-11-04 [?] RSPM (R 4.0.3) #> VP reprex 1.0.0 2019-05-16 [?] CRAN (R 4.0.2) #> VP rlang 0.4.10 2020-10-08 [?] CRAN (R 4.0.3) #> VP rmarkdown 2.7 2020-10-21 [?] RSPM (R 4.0.3) #> P sessioninfo 1.1.1 2018-11-05 [?] CRAN (R 4.0.3) #> P stringi 1.5.3 2020-09-09 [?] CRAN (R 4.0.3) #> P stringr 1.4.0 2019-02-10 [?] CRAN (R 4.0.3) #> R styler 1.3.2 [?] #> VP tibble 3.1.0 2020-10-12 [?] CRAN (R 4.0.3) #> P tidyselect 1.1.0 2020-05-11 [?] CRAN (R 4.0.3) #> P utf8 1.1.4 2018-05-24 [?] CRAN (R 4.0.3) #> VP vctrs 0.3.6 2020-08-29 [?] CRAN (R 4.0.3) #> VP withr 2.4.1 2020-09-22 [?] CRAN (R 4.0.3) #> VP xfun 0.21 2020-10-30 [?] RSPM (R 4.0.3) #> P yaml 2.2.1 2020-02-01 [?] CRAN (R 4.0.3) #> #> [1] /home/cl/Documents/ubep/covid19.icuve/renv/library/R-4.0/x86_64-pc-linux-gnu #> [2] /tmp/RtmpdyaVsw/renv-system-library #> #> V ── Loaded and on-disk version mismatch. #> P ── Loaded and on-disk path mismatch. #> R ── Package was removed from disk. ```

Possible related issue

211 ; r-lib/gargle#165

jennybc commented 3 years ago

Yes, you need to delete / recreate cached OAuth user tokens created with the previous built-in OAuth app:

https://github.com/r-lib/gargle/blame/c394e1a278880b08ea8d5f8fe7033532da8e266e/NEWS.md#L18

This is intentional. A broader announcement will come soon, after another update in googlesheets4 and gargle. We have some people using the built-in app excessively, e.g. in a tight loop with try() or similar, which exhausts quota for everyone. So we're rolling out some related changes.

We will disable the previous OAuth app sometime in the coming months (definitely with an announcement). Your workflow needs to be able to accommodate these sort of changes to the built-in credentials and, if it's hard, it's a strong sign that you should be using your own OAuth app or a service account token. OAuth tokens created with the built-in app are primarily for interactive use.

https://github.com/tidyverse/googlesheets4/blame/8e6dff1e30248f6b22476c69ae8a9481d5aaefce/NEWS.md#L5