gmailr and Shiny Server and authentication

Like many, I'm having trouble with the new authentication methods in the latest version of gmailr. After much gnashing of teeth I finally found pointers to how to create an app in google, download the json file, use gm_auth() to get the "secret", and if I run the following code in R studio:

gm_auth_configure(path = "gm_credentials/credentials.json")
gm_auth(email="email@domain.com", cache = ".secrets")

I can run gmailr mail functions successfully from the working directory I run the code in. (gm_credentials and .secrets are subfolders of the working directory). I can also, at that point, run shiny programs that use that working directory, but only locally in R Studio.

However, I cannot get any gmailr functionality working when the apps are run on Shiny Server. I've tried including the above code in the server.R file ("cannot get google credentials") and a million other things. I'm at a loss for what additional stuff needs to be added to satisfy the server.
Does anyone have a recipe for how to get gmailr to authenticate that works in the Shiny Server environment?
Thanks

..

I spend last night struggle in the same problem, and i got a solution here:

Hope this work for you.

Gretings!

Thanks for your reply. I have run into the issue you describe, with multiple tokens showing up in my cache that need to be deleted, but I still have one problem beyond that when I run it on the server.
Locally, the shiny program works fine, but when I access it from a browser it never makes it past the the call to gm_auth_configure(path = "path"). I've tried absolute paths. I've tried relative paths. I thought it might be a privilege issue, but the shiny user is the same as the local user. I am unable to see the error message generated by gm_auth_configure() so I don't know what's happening.
Thanks!

Now making it past gm_auth_configure but getting the dreaded "Cant get google credentials" when I try and run from the server and hit gm_auth(email="name.domain",cache=".secrets").

Is there any possible reason there would be a different secrets file when running from the server vs. running locally from R Studio?

Thanks

Given up and moved to emayili. A much simpler and more straightforward email package than either gmailR with its Java problems or gmailr with its oauth nightmares.