Googlesheets authorization on

I'm attempting to get write access to a googlesheet from a shiny app using the "service account token" approach described in In my app, this involves two lines:

googledrive::drive_auth(path  = "learnrcache-efcb19f92072.json")
passwd_df <-  sheets_read(key)

All works well when I am running the app on my development computer [I was wrong here.], but when I deploy to I get this error:

Error in value[[3L]](cond) : Can't get Google credentials.
Are you running googlesheets4 in a non-interactive session? Consider:
  * `sheets_deauth()` to prevent the attempt to get credentials.
  * Call `sheets_auth()` directly with all necessary specifics.
See gargle's "Non-interactive auth" vignette for more details:
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted

Any suggestions? I'm trying to create a package for instructors to log events from learnr tutorials in order to support the COVID-19 movement to online learning.

I haven't used the gargle package myself but I have authenticated with googlesheets in the past. Has learnrcache-efcb19f92072.json been uploaded to the shinyapps directory? I think that may have been for a one-time session only.

You may want to try googledrive::drive_auth_configure() first to store a key for use in downstream requests. Then you'll use your API key for all requests.

Thanks, Tanya. Indeed I did have learnrcache-efcb19f92072.json uploaded to the shinyapps directory.

I tried your suggestion to use googledrive::drive_auth_configure(), or at least I think I tried it. This is what I did

  1. Went to to create an API key.
  2. Ran oaauth_app()
myapp <- httr::oauth_app(
    "markr", # the name of the package implementing the system
    key = "the_key_I_got_in_step_1", 
    "a character string to use as a secret")
  1. In the app, called

googledrive::drive_auth_configure(app = myapp, api_key = mykey)

This doesn't work, either on my development computer or (not surprisingly) on

Is it the same error and if not can you post it?

I got this to work by following the example here:

1 Like