8

I have a Shiny app making use of the googlesheets package which requires the user to authenticate for writing to Google Sheets (despite the Sheet being public and "published to the web"). This is done graphically in a browser, and works when the Shiny app is run locally. However, when deployed on shinyapps.io, the authentication call crashes the app and logs an error:

Warning: Error in : oauth_listener() needs an interactive environment.

So, what options are there? I'm thinking it would be a bad idea to upload my own .httr-oauth file or token to shinyapps.io... Any workarounds?

Psidom
  • 209,562
  • 33
  • 339
  • 356
adatum
  • 655
  • 9
  • 23
  • When you say it is "published to the web" this usually only makes the file visible to users, not editable. When you say "public", the default behaviour here is also to make the file visible ("can view"), but this can be changed to "can edit" manually. Have you got the "can edit" setting selected? – rosscova Jul 06 '16 at 05:11
  • 1
    @rosscova Yes, the permissions were also changed to "anyone with link can edit" with no sign-in required (when accessing Google Sheets through a browser) and this was verified. – adatum Jul 06 '16 at 06:04

1 Answers1

2

In case anyone else has a problem with this, the new {googlesheets4} provides a solution:

https://googlesheets4.tidyverse.org/articles/articles/auth.html

If you don’t need to access private Sheets, use gs4_deauth() to indicate there is no need for a token. This puts googlesheets4 into a de-authorized mode.

(an example script is also included)

SOwla
  • 376
  • 2
  • 9
  • 1
    Unfortunately there is a 401 UNAUTHENTICATED error even when using `googlesheets4` and `gs4_deauth()`. It seems this is an issue with google's own absurd policy of requiring authentication via API on a publicly/anonymously editable sheet, even when the sheet can be anonymously edited in a browser. See https://github.com/tidyverse/googlesheets4/issues/168 and https://issuetracker.google.com/issues/36755576 – adatum Jun 17 '20 at 00:42