tidyverse / googlesheets4

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

gs4_auth thinks it is running in a non-interactive session but is being run in RStudio #303

Closed qwertytam closed 10 months ago

qwertytam commented 10 months ago

I'm trying to authorize using gs4_auth(cache = FALSE), however I get the error below when running the command in RStudio. I'm expecting to go through the browser dance, but this doesn't happen, even though I'm running this interactiely in RStudio.

Running on Apple M1 silicon Ventura 13.4.1, R v4.3.1, RStudio Version 2023.09.1+494, and using renv.

> gs4_auth(cache = FALSE)
trying `token_fetch()`
Trying `credentials_byo_oauth()` ...
Error caught by `token_fetch()`:
inherits(token, "Token2.0") is not TRUE
trying `credentials_service_account()`
Error caught by `token_fetch()`:
Argument 'txt' must be a JSON string, URL or file.
trying `credentials_external_account()`
aws.ec2metadata not installed; can't detect whether running on EC2 instance
trying `credentials_app_default()`
Trying `credentials_gce()` ...
✖ We don't seem to be on GCE.
trying `credentials_user_oauth2()`
attempt to access internal gargle data from: googlesheets4
Gargle2.0 initialize
adding "userinfo.email" scope
loading token from the cache
no matching token in the cache
initiating new token
Error caught by `token_fetch()`:
OAuth2 flow requires an interactive session.
Error in `gs4_auth()`:
! Can't get Google credentials.
ℹ Are you running googlesheets4 in a non-interactive session? Consider:
• Call `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>
Backtrace:
    ▆
 1. └─googlesheets4::gs4_auth(cache = FALSE)
 2.   └─googlesheets4:::gs4_abort(...)
 3.     └─cli::cli_abort(...)
 4.       └─rlang::abort(...)
jennybc commented 10 months ago

If I run:

library(googlesheets4)
gs4_auth(cache = FALSE)

I am taken to the browser and auth proceeds as normal. So we're going to need more details to get anywhere. Here are my current package versions, for comparison with yours:

> session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.1 (2023-06-16)
 os       macOS Ventura 13.6
 system   aarch64, darwin20
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Vancouver
 date     2023-11-03
 rstudio  2023.09.1+494 Desert Sunflower (desktop)
 pandoc   NA
 quarto   1.4.176 @ /usr/local/bin/quarto

─ Packages ────────────────────────────────────────────────────────────────────────────────
 package         * version    date (UTC) lib source
 askpass           1.2.0      2023-09-03 [1] RSPM
 aws.ec2metadata   0.2.0      2019-07-15 [1] CRAN (R 4.3.0)
 cachem            1.0.8      2023-05-01 [1] CRAN (R 4.3.0)
 callr             3.7.3      2022-11-02 [1] CRAN (R 4.3.0)
 cellranger        1.1.0      2016-07-27 [1] CRAN (R 4.3.0)
 cli               3.6.1.9000 2023-11-04 [1] Github (r-lib/cli@eeeb260)
 conflicted      * 1.2.0.9000 2023-07-04 [1] Github (r-lib/conflicted@99075d8)
 crayon            1.5.2      2022-09-29 [1] RSPM
 curl              5.1.0      2023-10-02 [1] RSPM
 devtools        * 2.4.5.9000 2023-11-04 [1] local
 dplyr             1.1.3      2023-09-03 [1] RSPM
 ellipsis          0.3.2      2021-04-29 [1] CRAN (R 4.3.0)
 fansi             1.0.5      2023-10-08 [1] RSPM (R 4.3.0)
 fastmap           1.1.1      2023-02-24 [1] CRAN (R 4.3.0)
 fs                1.6.3.9000 2023-10-03 [1] local
 gargle            1.5.2      2023-07-20 [1] local
 generics          0.1.3      2022-07-05 [1] CRAN (R 4.3.0)
 glue              1.6.2      2022-02-24 [1] RSPM
 googledrive       2.1.1.9000 2023-07-04 [1] Github (tidyverse/googledrive@74a69a3)
 googlesheets4   * 1.1.1      2023-06-11 [1] CRAN (R 4.3.0)
 httpuv            1.6.11     2023-05-11 [1] CRAN (R 4.3.0)
 httr              1.4.7      2023-08-15 [1] RSPM
 jsonlite          1.8.7      2023-06-29 [1] CRAN (R 4.3.0)
 later             1.3.1      2023-05-02 [1] CRAN (R 4.3.0)
 lifecycle         1.0.3      2022-10-07 [1] CRAN (R 4.3.0)
 magrittr          2.0.3      2022-03-30 [1] CRAN (R 4.3.0)
 memoise           2.0.1.9000 2023-08-02 [1] Github (hadley/memoise@588007a)
 openssl           2.1.1      2023-09-25 [1] RSPM
 pak             * 0.5.1      2023-04-28 [1] local
 pillar            1.9.0      2023-03-22 [1] RSPM
 pkgbuild          1.4.2      2023-06-26 [1] CRAN (R 4.3.0)
 pkgconfig         2.0.3      2019-09-22 [1] CRAN (R 4.3.0)
 pkgload           1.3.3.9000 2023-09-28 [1] Github (r-lib/pkgload@681b363)
 prettyunits       1.2.0      2023-09-24 [1] CRAN (R 4.3.1)
 processx          3.8.2      2023-06-30 [1] CRAN (R 4.3.0)
 promises          1.2.1      2023-08-10 [1] RSPM
 ps                1.7.5      2023-04-18 [1] CRAN (R 4.3.0)
 purrr             1.0.2      2023-08-10 [1] CRAN (R 4.3.0)
 R6                2.5.1      2021-08-19 [1] CRAN (R 4.3.0)
 Rcpp              1.0.11     2023-07-06 [1] RSPM
 remotes           2.4.2.1    2023-07-18 [1] RSPM
 reprex          * 2.0.2.9000 2023-07-04 [1] Github (tidyverse/reprex@b904f73)
 rlang             1.1.1      2023-04-28 [1] CRAN (R 4.3.0)
 rstudioapi        0.15.0     2023-07-07 [1] RSPM
 sessioninfo       1.2.2.9000 2023-10-08 [1] Github (r-lib/sessioninfo@dfb750d)
 tibble            3.2.1      2023-03-20 [1] CRAN (R 4.3.0)
 tidyselect        1.2.0      2022-10-10 [1] CRAN (R 4.3.0)
 usethis         * 2.2.2.9000 2023-11-02 [1] local
 utf8              1.2.4      2023-10-22 [1] RSPM
 vctrs             0.6.4      2023-10-12 [1] RSPM (R 4.3.0)
 withr             2.5.2      2023-10-30 [1] CRAN (R 4.3.1)

 [1] /Users/jenny/Library/R/arm64/4.3/library
 [2] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library

───────────────────────────────────────────────────────────────────────────────────────────
qwertytam commented 10 months ago

Can close this issue. Even though I thought I had successfully recreated the error in a clean environment multiple times, today I did the same thing and no error. So can call this closed, no further action required.