Juan Acosta
Juan Acosta

Reputation: 171

Unable to authenticate googlesheets package for R studio

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?

Upvotes: 1

Views: 1116

Answers (1)

Agile Bean
Agile Bean

Reputation: 7191

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.

Upvotes: 0

Related Questions