1

I'm trying to work in R studio and shiny with remote databases. For this purpose, I downloaded JennyBrian's package

install.packages("googlesheets")
library(googlesheets)

When I try to initiate the program I have to authorize my google account

gs_auth()

But I get stucked on thos step trying to open the browser

Waiting for authentication in browser... Press Esc/Ctrl + C to abort

Can enyone help me , please?

GGamba
  • 13,140
  • 3
  • 38
  • 47
Juan Acosta
  • 171
  • 1
  • 9
  • Are you running the script on a server or other computer without access to a browser? `gs_auth()` requires a browser for the first time to generate your token. After that one time, you can store as a file and reference it, without ever having to run through the browser based authentication. More details here: https://rawgit.com/jennybc/googlesheets/master/vignettes/managing-auth-tokens.html – Steven M. Mortimer Jun 13 '17 at 02:31

1 Answers1

0

you can avoid the browser authentication if you access a google sheet directly by its key. The key (sheet_key) is the long string in the URL of the sheet between "https://docs.google.com/spreadsheets/d/" and "/edit#gid=xxxxxx".

Then, you can get the sheet data by this short command:

survey.raw <- sheet_key %>%  gs_key(lookup = FALSE) %>% gs_read()

This doesn't work if you haven't made the sheet "public". For this, "publish as web page" and "share" the sheet.

Hope this helps.

Agile Bean
  • 6,437
  • 1
  • 45
  • 53
  • I really appreciate it. I've tried your code with my public key . But then I have this error message Error in stop_for_content_type(req, expected = "application/atom+xml; charset=UTF-8") : Expected content-type: application/atom+xml; charset=UTF-8 Actual content-type: text/html; charset=UTF-8 do you know how to handle it? Thank you – Juan Acosta Apr 08 '17 at 16:58
  • by the way, the public key is 14oTVME_8A-Zyk1gTy-_o_LENSQ8Lazr7rNODsRcarfs – Juan Acosta Apr 08 '17 at 17:04
  • Yes, I do. In fact, I already wrote you the answer: For this, "publish as web page" and "share" the sheet. – Agile Bean Apr 10 '17 at 00:27