Hello,
As someone unfamiliar with authorizations on googlesheets, I'm quite confused with creating a token that I can use to authorize. Here is what's happening:
I've set up a public (anyone with the link can edit) googlesheet where I hold tweet data. I've created a R script that pulls data from Twitter using rtweet
and then uses sheet_append
to append this data to the googlesheet:
# Load packages
library(tidyverse)
library(rtweet)
library(googlesheets4)
# Search for 1000 tweets, excluding retweets
# 400 ~ 600 Tweets on average per day. Safe to search for 1000 tweets and then filter out for each date.
rt <- search_tweets("#rstats", n = 1000, include_rts = FALSE) %>%
# Extract out dates
mutate(created_at = lubridate::date(created_at)) %>%
# Filter for today's tweets
filter(created_at == Sys.Date())
# Append tweet data to Googlesheets
sheet_append(ss = " https://docs.google.com/spreadsheets/d/1oaS3m5EqKRML7u3ma2EZaWPfhYOeAG-jgvy-HQ4FW-g/edit?usp=sharing",
data = rt,
sheet = "Sheet1")
I imagine that this won't work in a cronjob because it'd require authentication in a popup browser, when I run search_tweets
.
When I run sheet_append
, this message pops up:
A few years ago, when the googlesheets
package was alive, I used to just create a token (previous_token.rds
) and run gs_auth(token = "previous_token.rds")
.
I'd like to do the same with googlesheets4
package, but I can't figure out how. Could someone instruct me on how to create a token and authorize in googlesheets4
package, as I did with the googlesheets
package?
Thank you!