我想将服务帐户信息提供给" 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上运行良好,但似乎&#34; bq&#34;命令在配置&#34; gcloud&#34;之前不接受任何命令。或&#34; gsutil&#34;即使提供了服务帐户信息:
> 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.
我可以用&#34; bq&#34;达到这个目的吗?或不?我已尝试导出GOOGLE_APPLICATION_CREDENTIALS环境,但它似乎无法正常工作。
提前谢谢。
答案 0 :(得分:2)
对于“bq”中的身份验证,有“init”命令。但即使你跑:
bq init
系统返回以下警告:
The "init" command is no longer needed with the Cloud SDK.
To authenticate, run gcloud auth.
因此,似乎没有推荐的方法仅使用“bq”进行身份验证而不使用“gcloud”。