bigrquery切换认证邮箱失败求助:指定邮箱仍用工作邮箱认证
切换bigrquery认证邮箱遇到的问题
我尝试更换用于读取bigrquery数据的认证邮箱,但遇到了以下异常情况:
初始认证状态
执行以下代码:
bq_auth() bq_user()
返回当前认证的工作邮箱:
bq_user() [1] "MYEMAIL@biotech.com"
取消认证后重新指定邮箱
取消认证并尝试切换到gmail邮箱,结果仍回到工作邮箱:
> bq_deauth() > bq_user() NULL > bq_auth(email="MYEMAIL@gmail.com") > bq_user() [1] "MYEMAIL@biotech.com"
尝试通过gargle获取令牌(带权限范围)
直接调用gargle::token_fetch指定邮箱和权限范围,认证后还是工作邮箱:
> token = gargle::token_fetch(email="MYEMAIL@gmail.com",scopes = scopes) > bq_auth(token = token) > bq_user() [1] "MYEMAIL@biotech.com"
尝试通过gargle获取令牌(不带权限范围)
去掉权限范围后,成功切换到gmail邮箱,但执行查询时出现权限不足错误:
> token = gargle::token_fetch(email="MYEMAIL@gmail.com") > bq_auth(token = token) > bq_user() [1] "MYEMAIL@gmail.com"
执行查询报错:
> bq_tb <- bq_project_query("com-biotech-myproject", query="SELECT * FROM `com-biotech.CoolDataset.Fake2`") Error in `signal_reason()`: ! Request had insufficient authentication scopes. [insufficientPermissions] Run `rlang::last_trace()` to see where the error occurred.
请问这是bug还是我操作有误?
Session信息
> sessionInfo() R version 4.3.0 (2023-04-21) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.4 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0 locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 time zone: America/New_York tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] bigrquery_1.4.2 devtools_2.4.5 usethis_2.2.0 loaded via a namespace (and not attached): [1] rappdirs_0.3.3 utf8_1.2.3 generics_0.1.3 stringi_1.7.12 digest_0.6.31 magrittr_2.0.3 [7] grid_4.3.0 pkgload_1.3.2 fastmap_1.1.1 jsonlite_1.8.5 processx_3.8.1 pkgbuild_1.4.1 [13] sessioninfo_1.2.2 DBI_1.1.3 urlchecker_1.0.1 ps_1.7.5 promises_1.2.0.1 httr_1.4.6 [19] purrr_1.0.1 fansi_1.0.4 scales_1.2.1 cli_3.6.1 shiny_1.7.4 rlang_1.1.1 [25] crayon_1.5.2 dbplyr_2.3.2 bit64_4.0.5 ellipsis_0.3.2 munsell_0.5.0 remotes_2.4.2 [31] cachem_1.0.8 tools_4.3.0 gargle_1.5.0 memoise_2.0.1 dplyr_1.1.2 colorspace_2.1-0 [37] ggplot2_3.4.2 httpuv_1.6.11 curl_5.0.1 assertthat_0.2.1 vctrs_0.6.2 R6_2.5.1 [43] mime_0.12 lifecycle_1.0.3 stringr_1.5.0 bit_4.0.5 fs_1.6.2 htmlwidgets_1.6.2 [49] miniUI_0.1.1.1 pkgconfig_2.0.3 callr_3.7.3 pillar_1.9.0 later_1.3.1 gtable_0.3.3 [55] glue_1.6.2 profvis_0.3.8 Rcpp_1.0.10 tidyselect_1.2.0 tibble_3.2.1 rstudioapi_0.14 [61] xtable_1.8-4 htmltools_0.5.5 compiler_4.3.0 prettyunits_1.1.1 askpass_1.1 openssl_2.0.6
更新:临时解决方法
通过gargle::credentials_user_oauth2手动触发认证流程,成功切换到gmail邮箱:
token <- gargle::credentials_user_oauth2(scopes = scopes) The gargle package is requesting access to your Google account. Enter '1' to start a new auth process or select a pre-authorized account. 1: Send me to the browser for a new auth process. 2: MYEMAIL@gmail.com Selection: 1 Waiting for authentication in browser... Press Esc/Ctrl + C to abort Authentication complete. > bq_auth(token = token) > bq_user() [1] "MYEMAIL@gmail.com"
我怀疑gargle::token_fetch在该场景下存在问题,不清楚为何总是优先使用工作邮箱,会不会是之前的配置残留导致的?
内容的提问来源于stack exchange,提问作者HowYaDoing
相关产品推荐
相关产品推荐

