
Abmelden von Google Cloudscheintals ob es einfach sein sollte. Wenn ich ausführe:
$ unset GOOGLE_APPLICATION_CREDENTIALS
$ gcloud auth revoke --all
Revoked credentials:
- [my account]
$ gcloud auth list
No credentialed accounts.
To login, run:
$ gcloud auth login `ACCOUNT`
Es zunächstsieht ausals ob ich komplett abgemeldet wäre gcloud
. Aber sehen Sie, was passiert, wenn ich eine Python-Shell öffne:
>>> from google.cloud import secretmanager_v1beta1 as secretmanager
>>> client = secretmanager.SecretManagerServiceClient()
/Users/my/path/.venv/lib/python3.7/site-packages/google/auth/_default.py:66: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/
warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)
>>> path = client.secret_version_path(project="my-project-name", secret="my-secret", secret_version="latest")
>>> secret = client.access_secret_version(path)
>>> secret.payload.data.decode()
"Oh, no! I should be secret!"
gcloud auth revoke --all
Wie Sie sehen, kann ich trotz der Ausführung immer noch über das Python SDK auf Google Cloud zugreifen, wobei ich Benutzeranmeldeinformationen verwende, die irgendwo gespeichert sind. Gibt es eine Möglichkeit,vollständigvon Google Cloud auf meinem Laptop abmelden?
BEARBEITEN: Zur weiteren Klarstellung: Auf diesem Computer sind keine JSON-Dateien des Google Cloud Service-Kontos gespeichert und ich habe die GOOGLE_APPLICATION_CREDENTIALS
Umgebungsvariable aufgehoben.
Antwort1
Ich bin nicht sicher, ob Ihnen das irgendwie hilft, aber ich bin auf ein ähnliches Problem gestoßen. Nachdem ich alle Anmeldeinformationen mit dem Befehl widerrufen hatte, gcloud auth revoke --all
konnte ich immer noch Skripte in meiner Umgebung ausführen. Am Ende fand ich die Datei mit den Standardanmeldeinformationen der Anwendung in~/.config/gcloud/application_default_credentials.json. Durch Umbenennen oder Löschen dieser Datei konnten die Anmeldeinformationen vollständig widerrufen werden. Und jetzt hat die Client-Bibliothek keinen Zugriff mehr auf die Umgebung:
File "audit_test.py", line 8, in main
client = resource_manager.Client()
File "fake_path/python3.7/site-packages/google/cloud/resource_manager/client.py", line 72, in __init__
super(Client, self).__init__(credentials=credentials, _http=_http)
File "fake_path/python3.7/site-packages/google/cloud/client.py", line 132, in __init__
credentials, _ = google.auth.default()
File "fake_path/python3.7/site-packages/google/auth/_default.py", line 321, 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
Antwort2
Wie oben kommentiert vonAbonnieren, gcloud auth application-default revoke
funktioniert. Drücken Sie einfach den Befehl und die Anmeldeinformationen werden entfernt application-default
. Sehen Sie den UnterschiedHier. Ich hatte das gleiche Problem und nur das hat funktioniert.
Bearbeiten:
Denken Sie daran, dass Sie dennoch anrufen müssen, gcloud auth revoke --all
da dadurch gcloud auth application-default revoke
nur die Standardanmeldeinformationen der Anwendung entfernt werden.