Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent exposure of my password when using RGoogleDocs?

Tags:

I love RGoogleDocs and use it a lot. However, I don't like entering my password all the time. Obviously I could just type the password into the R script and would never have to enter it again. But thats not viable since it means that my password would be left unencrypted on my harddrive. Furthermore I share my scripts with colleagues.

To get around the problem I came up with this.

if(exists("ps")){   print("got password, keep going") } else {   ps <-readline(prompt="get the password in ") }  options(RCurlOptions = list(   capath = system.file("CurlSSL", "cacert.pem",    package = "RCurl"), ssl.verifypeer = FALSE) )  sheets.con = getGoogleDocsConnection(   getGoogleAuth("[email protected]", ps, service ="wise"))   #WARNING: this would prevent curl from detecting a 'man in the middle' attack ts2=getWorksheets("hpv type",sheets.con) 

I love using RStudio. I feel uncomfortable that it is displaying my password for any colleague in my office at the time to see. I used a fake password but look at the image. my password would be in plain view for all to see in RStudio. Furthermore, if I saved a workspace my password would be saved with it and I am afraid that I would be giving it to someone else if, a few months later, when I had long forgotten about what was in it, I sent my .RData file to a colleague.

I read something general about passwords in R in an earlier post. It did not give me enough information to be able to conceal my password when using RGoogleDocs.

like image 802
Farrel Avatar asked May 23 '11 18:05

Farrel


2 Answers

My approach is to set the login-name & password in the R options list within the R startup file .Rprofile. Then my code gets the value with getOption() and then the value is never visible or stored in a top-level variable in globalenv(). (It could be save if one does post-mortem debugging via dump.frames).

It is vital that the .Rprofile cannot be read by anybody other than you.

So

options(GoogleDocsPassword = c(login = 'password')) 

in the .Rprofile and then

auth = getGoogleAuth() 

just works as the default value for the first parameter is to look for the GoogleDocsPassword option.

D.

like image 75
Duncan Avatar answered Oct 16 '22 09:10

Duncan


I had the same problem, and no real solution. The workaround I use is, I create a google account just for this purpose, with a password that I do not care about. I then share the documents that I want R to access with that account.

But if someone has an answer to the initial question I am interested as well.

like image 20
crayola Avatar answered Oct 16 '22 10:10

crayola