Gmailr without interactive authorization

Is it possible to send email using gmailr without any interactive authorization? I assumed that was what the credentials.JSON route was for, but I haven't been able to get it to work, and @jennybryan's example says "No matter what, the first time, you should get kicked into a browser to authenticate yourself...", which isn't possible in my case. I'd be okay putting any credentials right in the script -- it's a send-only gmail account that just says "this thing happened". Thanks.

The JSON file re: gmailr just holds client ID and secret (which aren't really secret, btw, in this case).

Given gmail's current design, I think you must go through the interactive process once. This should cause a refresh token to be stored in .httr-oauth. And then you need to put that file in working directory for auto discovery by the script that's going to send mail for you, non-interactively.

2 Likes

Hello, this approach works well with a local (desktop) Rstudio, but not when I use a remote RStudio. I'm redirected to a new browser page pointing to http://localhost:1410 . Any idea how I could solve that? I need to use gmailr in remote RStudio.

Thanks in advance for your advice,
Emmanuel