[英]Connect to a GCP Cloud SQL Auth Proxy using SQL alchemy and a GCP service account
[英]GCP Authenticate as End User using gcloud auth (not service account)
在我的 GCP VM (ubuntu) 服務器上,如果我運行:
gcloud init
在終端中,並以我的用戶名(不是服務帳戶)登錄,例如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)
但是,當我在本地 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
我不想使用服務帳戶。 我想使用最終用戶憑據進行身份驗證(不使用流程)。
解決方案:
跑
gcloud auth application-default login
在 Windows 機器中,並以您想要的用戶身份登錄。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.