使用R从Google云存储中提取图像文件

使用R从Google云存储中提取图像文件,r,google-cloud-storage,R,Google Cloud Storage,我设法生成密钥和令牌,以便能够从r控制台中访问google云存储文件 然而,在执行下面的代码时,我遇到了下面的错误- Error: $installed not found in JSON - have you downloaded the correct JSON file? (Service account client > Desktop, not Service Account Keys) 虽然代码已经从之前的SO帖子中得到了解决/提供,但这个错误对我来说

我设法生成密钥和令牌,以便能够从r控制台中访问google云存储文件

然而,在执行下面的代码时,我遇到了下面的错误-

Error: $installed not found in JSON - have you downloaded the correct JSON file? 
           (Service account client > Desktop, not Service Account Keys)
虽然代码已经从之前的SO帖子中得到了解决/提供,但这个错误对我来说仍然是个谜

--所以在下面发帖子

--完整代码如下

rm(list = ls(all.names = TRUE))
options(java.parameters = "-Xmx8000m")

library(googleCloudStorageR)
library(googleAuthR)
library(jsonlite)


# for working in google cloud storage

GCS_AUTH_FILE = "serviceaccount.json"  
GAR_CLIENT_WEB_JSON = "Oauthclient.json"
# fromJSON(GCS_AUTH_FILE)
# fromJSON(GAR_CLIENT_WEB_JSON)

gar_auth_service(GCS_AUTH_FILE)

#set the scope
gar_set_client(scopes = c("https://www.googleapis.com/auth/devstorage.read_write",
                          "https://www.googleapis.com/auth/cloud-platform"), json = GAR_CLIENT_WEB_JSON
)    

您似乎没有使用正确的JSON文件。我发现这篇文章提到了如何正确配置它

以下是步骤:

  • 启用Google云存储API
  • 凭据>>创建凭据>>OAuth客户端ID>>其他
  • 将JSON文件保存为类似my-ClientID-credentials.JSON的格式 凭据>>创建凭据>>服务帐户密钥
  • 将JSON文件另存为类似my-service-account-credentials.JSON的内容
  • 这是文章中提到的代码

    #谷歌云存储
    #设置
    图书馆(谷歌云存储)
    选项(googleAuthR.scopes.selected=”https://www.googleapis.com/auth/devstorage.full_control")
    #验证客户端ID
    googleAuthR::gar_set_client(“path/to/my ClientID credentials.json”)
    #验证服务帐户
    Sys.setenv(“GCS_AUTH_FILE”=“full/path/to/my-service-account-credentials.json”)
    googleCloudStorageR::gcs_auth()
    ##获取桶信息
    gcs_列表_bucket(projectId=“我的项目”)
    
    您似乎没有使用正确的JSON文件。我发现这篇文章提到了如何正确配置它

    以下是步骤:

  • 启用Google云存储API
  • 凭据>>创建凭据>>OAuth客户端ID>>其他
  • 将JSON文件保存为类似my-ClientID-credentials.JSON的格式 凭据>>创建凭据>>服务帐户密钥
  • 将JSON文件另存为类似my-service-account-credentials.JSON的内容
  • 这是文章中提到的代码

    #谷歌云存储
    #设置
    图书馆(谷歌云存储)
    选项(googleAuthR.scopes.selected=”https://www.googleapis.com/auth/devstorage.full_control")
    #验证客户端ID
    googleAuthR::gar_set_client(“path/to/my ClientID credentials.json”)
    #验证服务帐户
    Sys.setenv(“GCS_AUTH_FILE”=“full/path/to/my-service-account-credentials.json”)
    googleCloudStorageR::gcs_auth()
    ##获取桶信息
    gcs_列表_bucket(projectId=“我的项目”)