Although it's not my main language, I'm using R to post results from a daily ETL into a Google Sheets worksheet. Because this is going to be a scheduled job that runs in perpetuity, I'm hesitant to use the interactive flow for authenticating Google Drive from R. I have the path for my JSON from my Google Drive account credentials, but when I pass
gs4_deauth()
gs4_has_token()
gs4_auth(email=<email-string>, path = jsonlite::fromJSON(<path-to-json>), cache = NULL)
it throws the following error:
[1] FALSE
Error: Can't get Google credentials.
Are you running googlesheets4 in a non-interactive session? Consider:
* `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
Execution halted
Since the error message doesn't provide much specifics, I'm wondering if anyone has experience with this or has any ideas why this could be occurring? I'm using gs4_deauth() because I had originally logged in using the interactive flow, but want to now ensure that non-interactive authentication works.
As an aside, what's the least painful way to make a token object from the json credentials file? I believe that may be simpler than repeatedly passing the json credentials directly using the path
argument.