我只有在一张纸已经被授权的情况下才能阅读它,
如果不是,后续的每一行代码都会被忽略,因为代码执行一直在请求令牌。有没有办法将令牌索引传递到read_sheet命令中,或者是否有某种方法可以预先授权访问?
> aa <- read_sheet('https://docs.google.com/spreadsheets/d....', sheet='Akinesia', range="AC:AH")
The googlesheets4 package is requesting access to your Google account. Select a pre-authorised account or enter '0' to obtain a new token. Press Esc/Ctrl + C to abort.
1: chris.elliott@.....
Selection:
Enter an item from the menu, or 0 to exit
Selection:
Enter an item from the menu, or 0 to exit
Selection:
Enter an item from the menu, or 0 to exit
Selection: aaX <- aa %>% filter_all(any_vars(!is.na(.)))
Enter an item from the menu, or 0 to exit
Selection: akns <- aaX %>% pivot_longer(-genotype, names_to = "day", values_to = "nonresp")
Enter an item from the menu, or 0 to exit发布于 2020-10-29 18:19:48
您需要进行auth调用,该调用提供不同的身份验证方法:
默认身份验证
尝试不带参数或使用与Google帐户关联的电子邮件地址的默认呼叫:
googlesheets4::gs4_auth(email = "chris.elliott@...")服务帐户
您还可以传递与服务帐户关联的令牌文件:
googlesheets4::gs4_auth(path = "access_token.json")jsonlite::fromJSON()的txt参数所支持的一种格式(通常是文件路径或
字符串)。
含口令牌
googlesheets4使用gargle包,因此您也应该能够像这样获得令牌:
library(gargle)
token <- token_fetch()
googlesheets4::gs4_auth(token = token)https://stackoverflow.com/questions/64589029
复制相似问题