Authenticating Gmail from gmailr package

In my shiny app, I am using the gmailr function to authenticate my gmail account. On my local machine this works great. When I deployed my app it didn't work.

The expected result after running the following function is a popup asking me to choose which gmail account to authenticate. When I ran the app, instead of a pop-up, it showed the url to copy and paste in the logs instead of the pop-up appearing.

This is the following code in the app:


Has anyone tried using this package in

1 Like

I think you probably have to upload the .httr-oauth file created locally to the server. It's also possible you'll have to set the httr_oob_default parameter. I'd recommend this article to generally get a better feeling for the topic:

And this QA might be helpful for you specifically on

I think that your first two lines are conflicting -- in that the first says you want to cache your token and the second clears it. I'd suggest deleting the gmailr::clear_token() line, assuming you're ok with cacheing your token.


Hi Alex,

Thanks for the suggestion!

I am still struggling unfortunately.

I changed my code to look like this:


Then when this runs, it prompts me to copy and paste this token to my r-console.

4/GQF@JjszXNfafdjklafjdsalkfaeffaefklj (not real token)

Then when I copy and paste it into the rconsole, nothing happens after I paste it.

I also tried taking this token and copying and pasting it to the .httr-oath file and still no luck.

It would be really helpful if you can provide a simple sample code on how this could be done if you have experience with this. Appreciate the help so far!

Hi @nickknauer1,

If you do this right, it shouldn't ask for authentication on the server because the .httr-oauth token is there already.

I'd recommend creating it locally and then copying it up when you go to (option 3 here).

These are the steps:

  1. Run options(httr_oob_default = TRUE, httr_oauth_cache=TRUE) (maybe not necessary) on your local machine.
  2. Run gmailr::gmail_auth() on your local machine and follow the steps.
  3. Check that it worked correctly by running gmailr::gmail_auth(). If you hit enter and nothing happens, it's worked correctly.
  4. Find the file titled .httr-oauth (probably in the base directory of the project) and copy that with your project up to

Hope that's helpful!

1 Like

Hi Alex,

Thank you for the help!

This now works. Appreciate it.



1 Like

Hi @nickknauer1,

If you wouldn't mind, could you accept your favorite solution? You can do that by hitting the three dots next to Reply and then the little check mark.

Thanks for being part of the community!