如何获得gcloud auth activate-service-account坚持 [英] How to get gcloud auth activate-service-account persist
问题描述
我使用bq命令行工具从BigQuery表中查询。有没有办法让服务帐户身份验证在我登录和退出查询过程时运行的框中保留?
我做过的步骤: p>
- 我通过运行以下方式验证服务帐户:
-
gcloud auth activate-service-account --key-file /somekeyFile.p12 someServiceAccount.gserviceaccount.com
$ c $
从bigquery表中查询,这工作正常:
bq --project_id = formal-cascade-571查询select * from dw_test.clokTest
然后我从框中注销并重新登录。当我再次查询BigQuery表时:
bq --project_id = formal-cascade-571查询select * from dw_test.clokTest
它给了我错误:
您当前的活动帐户[someServiceAccount.gservic
即使我传入私钥文件:
bq --service_account = someServiceAccount.gserviceaccount.com --service_account_credential_file =〜/ clok_cred.txt --service_account_private_key_file = / somekeyFile.p12 --project_id = formal -cascade-571查询select * from dw_test.clokTest
它给出了相同的错误:
您当前的活动帐户[someServiceAccount.gserviceaccount.com]没有任何有效的凭证。
因此,每次我需要通过以下方式重新验证我的服务帐户:
gcloud auth activate-service-account
有没有办法让认证的服务帐户凭证持久存在?
我问了GCloud的开发人员和他们会除非设置了环境变量 CLOUDSDK_PYTHON_SITEPACKAGES
,否则服务帐户不会显示。
希望这很快就会被修复,但是在此期间,当你再次登录时,你可以试试跑吗?
pre> export CLOUDSDK_PYTHON_SITEPACKAGES = 1
然后看看它是否有效?
您可以运行
gcloud auth list
查看哪些帐户有凭据;它应该列出你的服务帐户。
I am using the bq command line tool to query from a Bigquery table. Is there a way to get the service account authentication to persist when I logged in and out of the box that the query process is running on?
Steps I did:
- I logged into the linux box
Authenticate service account by running:
gcloud auth activate-service-account --key-file /somekeyFile.p12 someServiceAccount.gserviceaccount.com
Query from bigquery table, this works fine:
bq --project_id=formal-cascade-571 query "select * from dw_test.clokTest"
But then I logged out from the box, and logged back in. When I query the Bigquery table again:
bq --project_id=formal-cascade-571 query "select * from dw_test.clokTest"
It gives me the error:
Your current active account [someServiceAccount.gserviceaccount.com] does not have any valid credentials.
Even when I pass in the private key file:
bq --service_account=someServiceAccount.gserviceaccount.com --service_account_credential_file=~/clok_cred.txt --service_account_private_key_file=/somekeyFile.p12 --project_id=formal-cascade-571 query "select * from dw_test.clokTest"
It gives the same error:
Your current active account [someServiceAccount.gserviceaccount.com] does not have any valid credentials.
So every time I need to re-authenticate my service account by:
gcloud auth activate-service-account
Is there a way to have the authenticated service account credential persist?
Thank you for your help.
I asked the GCloud devs and they mention a known bug where service accounts don't show up unless the environment variable CLOUDSDK_PYTHON_SITEPACKAGES
is set.
Hopefully this will be fixed soon, but in the meantime, when you log in again, can you try running
export CLOUDSDK_PYTHON_SITEPACKAGES=1
and seeing if it then works?
You can run
gcloud auth list
to see what accounts there are credentials for; it should list your service account.
这篇关于如何获得gcloud auth activate-service-account坚持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!