简体   繁体   English

GCP 使用 gcloud auth(不是服务帐户)以最终用户身份进行身份验证

[英]GCP Authenticate as End User using gcloud auth (not service account)

On my GCP VM (ubuntu) server, if I run:在我的 GCP VM (ubuntu) 服务器上,如果我运行:

gcloud init

in the terminal, and log in as my username (NOT A SERVICE ACCOUNT), eg my.name@companyname.com , then I can be authenticated as my user self, and am authenticated for all gcp related python functions.在终端中,并以我的用户名(不是服务帐户)登录,例如my.name@companyname.com ,然后我可以作为我的用户自己进行身份验证,并通过所有与 gcp 相关的 python 功能进行身份验证。

>>> import google.auth
>>> credentials, project = google.auth.default()
UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. We recommend you rerun `gcloud auth application-default login` and make sure a quota project is added. Or you can use service accounts instead. For more information about service accounts, see https://cloud.google.com/docs/authentication/
warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)

However, when I follow the same process on my local windows machine, I get this error:但是,当我在本地 Windows 机器上执行相同的过程时,出现此错误:

>>> import google.auth
>>> credentials, project = google.auth.default()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ProgramData\Anaconda3\lib\site-packages\google\auth\_default.py", line 354, in default
    raise exceptions.DefaultCredentialsError(_HELP_MESSAGE)
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the
 application. For more information, please see https://cloud.google.com/docs/authentication/getting-started

I do not want to use a service account.我不想使用服务帐户。 I want to be authenticated using end user credentials (Without using flow).我想使用最终用户凭据进行身份验证(不使用流程)。

Solution:解决方案:

Run

gcloud auth application-default login

in the windows machine, and login as the user you want.在 Windows 机器中,并以您想要的用户身份登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 SQL alchemy 和 GCP 服务帐户连接到 GCP Cloud SQL Auth Proxy - Connect to a GCP Cloud SQL Auth Proxy using SQL alchemy and a GCP service account GCP:允许服务帐户模拟具有 Google Analytics 范围的用户帐户 - GCP: Allow Service Account to Impersonate a User Account with Google Analytics Scopes 从GCloud激活服务帐户 - Activate Service Account from GCloud Google Cloud - 如何在应用程序代码中对用户而不是服务帐户进行身份验证? - Google Cloud - How to authenticate USER instead of a service account in app code? Google云服务帐户VS. 最终用户帐户 - Google Cloud Service Account VS. End User Account 关于如何使用 python 列出 gcp 服务帐户密钥的任何想法 - Any idea of how to list gcp service account keys using python GCP服务帐户密钥轮换 - GCP Service Account Key Rotation 在没有服务帐户的情况下使用gcloud登录colab - Login on colab with gcloud without service account 无法使用python脚本和GCP服务帐户信用将upload_from_filename文件上传到GCP存储桶 - Not able to upload_from_filename files into GCP bucket using python script and GCP service account cred 如何使用 Python 中的服务帐户向 Google Cloud 进行身份验证? - How to Auth to Google Cloud using Service Account in Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM