首页 文章

如何使用服务帐户和bigrquery包进行身份验证?

提问于
浏览
1

我已经能够使用 googleAuthbigQueryR 使用与服务帐户关联的json文件进行身份验证 .

# Load Packages
global.packages <- c("bigQueryR", "googleAuthR")

### Apply require on the list of packages; load them quietly
lapply(global.packages, require, character.only = TRUE, quietly = TRUE)

Sys.setenv("GCS_AUTH_FILE" = "json_file_location")

#Authenticate Google BQ
googleAuthR::gar_attach_auto_auth("https://www.googleapis.com/auth/bigquery",
                                  environment_var = "GCS_AUTH_FILE")

这有效,我可以开始使用 bigQueryR 中的函数 .

现在假设我仅限于 bigrquery 包,如何使用此包的服务帐户进行身份验证?

我看过这里的文档无济于事:https://cran.r-project.org/web/packages/bigrquery/bigrquery.pdf

我在互联网上遇到的资源建议使用 bigQueryR 包代替 bigrquery .

例如,这个相关的stackoverflow问题:Use bigrquery auth in shiny application .

但我需要仅在 bigrquery 中提供的功能 .

1 回答

  • 5

    您可以使用 bigrquery 中的函数 set_service_token() 使用您在 bigQueryR 中使用的相同服务JSON进行身份验证

    library(bigrquery)
    
    set_service_token("location-of-service.json")
    

    资料来源:https://github.com/rstats-db/bigrquery/issues/22

相关问题