I have an interactive shiny app which wants to read and write to a user's own Google Drive account. It is using gs4_create
, gs4_find
and range_read
from packages googlesheets4
and googledrive
.
When run locally, I get a prompt like this on first usage for each of these packages in turn through the console:
The googledrive package is requesting access to your Google account. Select a pre-authorised account or enter '0' to obtain a new token. Press Esc/Ctrl + C to abort
1: notmyemail@gmail.com
I can just select my gmail account or enter 0 to open the "Choose an account to continue to Tidyverse API Packages" GUI in the browser. Both methods work to (OAuth) authenticate the user and the functions work just fine.
When I deploy the app to shinyapps.io it throws an error on first usage of these functions without even requesting credentials:
Error in value[3L] : Can't get Google credentials. Are you running googledrive in a non-interactive session? Consider:
drive_deauth()
to prevent the attempt to get credentials.Call drive_auth()
directly with all necessary specifics. Read more in: https://gargle.r-lib.org/articles/non-interactive-auth.html
Obviously, I'm not looking for a console request on the deployed app, but what I think I need is to get the Tidyverse API GUI to trigger (which I assume is the intended behaviour) and enable a user to authenticate their account?
Note that (i) this app is interactive, (ii) the user is seeking to access private files on their own Google Drive, not a communal or public file. For both reasons, I cannot just supply a token.
The documentation for drive_auth_config
states that I could set up my own OAuth app to authenticate, but is this necessary?
Any ideas? Thanks.
I enquired on github and the developer of the googlesheets4
package, responded that multi-user authentication in shiny is not yet implemented. The issue is being tracked here: https://github.com/r-lib/gargle/issues/14