【问题标题】:How to change Google Accounts using library(googlesheets)?如何使用库(googlesheets)更改 Google 帐户?
【发布时间】:2015-12-28 00:10:19
【问题描述】:

我遇到了一些问题。我在一台机器上成功使用了 R-Script。在不同的计算机上使用相同的脚本会导致问题:

# Here I register the sheet 

browser <- gs_title("Funnel Daily")

browser<-gs_edit_cells(ws="Classic Browser", browser, input = ClassicBrowser, anchor = "A1",byrow = FALSE, col_names = NULL, trim = F,verbose = TRUE)

Auto-refreshing stale OAuth token.
Error in gs_lookup(., "sheet_title", verbose) : 
 "Funnel Daily" doesn't match sheet_title of any sheet returned by gs_ls() (which        should reflect user's Google Sheets home screen).
   > browser <- gs_title("Funnel Daily")
Error in gs_lookup(., "sheet_title", verbose) : 
  "Funnel Daily" doesn't match sheet_title of any sheet returned by gs_ls() (which   should reflect user's Google Sheets home screen).`

如果使用gl_ls(),我会收到一条关于我也经常使用的谷歌帐户的消息。那么有没有办法通过令牌左右来区分帐户,或者我该如何解决issue。我的意思是如何强制googlesheets 访问某些特定帐户? 目前我正在使用与Funnel Daily 对应的帐户的token。我能想到的唯一可能导致问题的可能性是浏览器身份验证是使用不包括Funnel Daily的帐户完成的。我只是把他们弄糊涂了。 我试图删除 googlesheets 以及 httr 的所有依赖项。但是当运行library(googlesheets) 并询问gs_user googlesheets 时,总是指不包含特定工作表的帐户。

【问题讨论】:

  • gs_auth 返回一个“令牌”。每个令牌都可以保存到 R 数据文件中,然后将 to 调用传递给gs_auth 以更改当前会话的内部保存令牌。您可能在使用googlesheets 之后缓存了凭据,并且缓存文件应该是您主目录中的.httr-oauth

标签: r r-googlesheets


【解决方案1】:

包含您的凭据并通过您的 Funnel Daily Google 帐户确认browser authentication

 options(googlesheets.client_id = "",
    googlesheets.client_secret = "",
    googlesheets.httr_oauth_cache = FALSE)

gs_auth(token = NULL, new_user = FALSE,
    key = getOption("googlesheets.client_id"),
    secret = getOption("googlesheets.client_secret"),
    cache = getOption("googlesheets.httr_oauth_cache"), verbose = TRUE)

干杯

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    • 1970-01-01
    • 2016-02-23
    • 2017-02-05
    • 2020-07-12
    • 1970-01-01
    相关资源
    最近更新 更多