So I have written a code that reads data from google sheets. Depending on what is in that data, it sends an email using information from the data. Then, it will write back the newly formatted data back to google sheets. While this all works when I run R studio myself, it has more issues when using cronR to schedule the script automatically on a Mac computer. It was working non-interactively for one (ie, worked for only gmailR), but when adding another program, it would no longer run by itself.
I have tried to follow the instruction of this post:
Gmailr without selecting a pre-authorised account in R
But I am still having issues. So I ran the interactive code first for each program. This meant:
json <- "path_to_file.json"
gm_auth_configure(path = json)
gm_auth(email = "[email protected]", cache = ".secret")
and
gs4_auth_configure(path = json)
gs4_auth(email = "[email protected]", cache = ".secret2")
This redirects me to authenticate the app on google. It also prompts me to give access to edit, read, change, emails and google sheets. I only run the above code once, and I then add this code to my script, which I believe should allow for non-interactive running.
json <- "path_to_file.json"
gm_auth_configure(path = json)
options(
gargle_oauth_cache = ".secret",
gargle_oauth_email = "[email protected]"
)
gm_auth(email = "[email protected]")
gs4_auth_configure(path = json)
options(
gargle_oauth_cache = ".secret2",
gargle_oauth_email = "[email protected]"
)
gs4_auth(email = "[email protected]")
I only send emails using gm_from("[email protected]")
as well so this is not the issue. Any advice on this would be amazing and help a massive amount for my project. Thanks for your help!