Configure .httr-oauth

Greetings.
Let stay I am in folder x and I run
gmailr::send_message(mime(from = "a@gmail.com",
to = "b@gmail.com",
subject = "R Progress",
body = "xx"))

Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
It will create two files (.gitignore and .httr-oauth) inside x

Then If I changed my working directory to another folder y and run
gmailr::send_message(mime(from = "a@gmail.com",
to = "b@gmail.com",
subject = "R Progress",
body = "xx"))

Again it will ask me for authentication.

I am wondering if I could have one authentication folder to look in, better for asking for authentication every time i change my working directory.

It is likely that future Google-wrapping packages from the tidyverse/r-lib team, at least, will implement what you say: a centrally managed store for Google auth. You could then switch between multiple identities and reuse tokens across projects and/or different APIs/packages.

It doesn't look like gmail currently supports user providing a path to .httr-oauth, although the underlying httr package does and some packages do expose that.

You can move .httr-oauth files, if that helps. Although I have never tried it (and it doesn't seem like a great idea, long-term), you might be able to share a common .httr-oauth across multiple gmailr projects via a symbolic link.

1 Like