You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

R升级至4.2.2后RStudio中bigrquery::bq_auth认证失败,R终端正常

问题:RStudio中bigrquery认证失败(R 4.2.2升级后)

问题详情

R版本升级至4.2.2后,RStudio调用bigrquery::bq_auth()时出现认证失败,但R终端会话可正常运行,导致Shiny应用无法启动。

运行代码:

json="The_file.json"
bigrquery::bq_auth(path = jason)

报错信息

Error: Can't get Google credentials.
Are you running bigrquery in a non-interactive session? Consider:
Call bq_auth() directly with all necessary specifics.

预期正常提示(R终端中)

The bigrquery 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 cancel.

解决思路

  • 修复变量拼写错误:代码中path = jason应为path = json,变量名不一致会导致无法读取指定的密钥文件,这是首要排查点。
  • 强制启用交互式认证:RStudio升级后可能误将会话识别为非交互式,可通过两种方式调整:
    # 方式1:设置环境变量标记为交互式会话
    Sys.setenv("R_INTERACTIVE" = "true")
    bigrquery::bq_auth(path = json)
    
    # 方式2:指定use_oob参数开启外置浏览器认证
    bigrquery::bq_auth(path = json, use_oob = TRUE)
    
  • 更新bigrquery包:R版本升级后,同步更新bigrquery到最新版本,解决版本兼容问题:
    install.packages("bigrquery")
    
  • 清除认证缓存:RStudio可能留存旧的认证缓存,重置后重新认证:
    bigrquery::bq_deauth()
    # 重启RStudio后再次调用bq_auth
    
  • Shiny应用适配方案:Shiny应用建议使用服务账号密钥文件做无交互认证,避免依赖交互式提示:
    # 直接指定服务账号密钥路径
    bigrquery::bq_auth(path = "/绝对路径/到/你的/service-account-key.json")
    

内容的提问来源于stack exchange,提问作者Leandro Alves

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 19:25:29