tidyverse/googledrive

drive_auth using callr on shinyapps.io

Closed this issue · 2 comments

dcaud commented

I'm having trouble using drive_auth() inside a background r process, using library(callr), when hosted on shinyapps.io.

Because callr opens a new r process, I need to explicitly pass all needed parameters in callr::r_bg.

I pass email and the path, like this:

  googledrive::drive_auth(
    email = "exampleEMAIL@something.com",
    path = google.json)

where google.json is created by:

google.json <- readLines("path/TheFile.json")

This seems to work intermittently or not at all, but sometimes definitely fails. There is no message or error created if it fails (my guess is that it hangs on drive_auth() inside the background R process).

Any ideas?

dcaud commented

To clarify somewhat, doing the same process outside of callr::r_bg works fine, so I am likely not passing something (a library or variable) to it that is needed by googledrive.

Leaving aside the callr and shiny aspects, this code is sending mixed messages.

The inclusion of email suggests that you want to auth as the user exampleEMAIL@something.com.

But, contradicting that, the inclusion of path suggests that you want to auth as the service account whose credentials are stored in google.json. Here is the meaning of the path argument of drive_auth():

`path`

JSON identifying the **service account**, in one of the forms supported for the txt argument of [jsonlite::fromJSON()](https://rdrr.io/pkg/jsonlite/man/fromJSON.html) (typically, a file path or JSON string).

So you either need to omit email or omit path.

If you mean to include email and you are trying to specify your own OAuth client, that must be done in a previous step, using drive_auth_configure().

No matter what you don't need to use readLines(). Just provide the filepath to the JSON file.