如何在没有 gcloud 或 gsutil 的情况下设置 "bq" (bigquery) shell 命令?



我想把服务账户信息外赋给"bq"命令作为参数,以便灵活更改其认证。我将一些选项传递给"bq"命令,如:

$ bq load --service_account=<my_service_account>
          --service_account_credential_file=<credential_output>
          --service_account_private_key_file=<path_to_pem>
          --project_id=<my_project>
          <dataset>.<table> <localfile> <schema>

使用我的帐户配置gsutil后,它在我的本地PC上运行良好,但似乎"bq"命令在配置"gcloud"或"gsutil"之前不接受任何命令,即使给出了服务帐户信息:

> You do not currently have an active account selected.
> Please run:
> 
> $ gcloud auth login
> 
> to obtain new credentials, or if you have already logged in with a different account:
>     
> $ gcloud config set account ACCOUNT
> 
> to select an already authenticated account to use.

我能不能用"bq"达到这个目的?我已经尝试导出GOOGLE_APPLICATION_CREDENTIALS环境,但它似乎不工作。

提前感谢。

对于"bq"中的鉴权,有"init"命令。但是即使你运行:

bq init

系统返回以下警告:

The "init" command is no longer needed with the Cloud SDK.
To authenticate, run gcloud auth.

因此,似乎没有推荐的方法可以仅从"bq"进行身份验证,而不使用"gcloud"。

最新更新