
Google Cloud에서 로그아웃것 같다마치 쉬워야 하는 것처럼요. 내가 실행하면 :
$ 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`
처음에는외모마치 에서 완전히 로그아웃된 것처럼 말이죠 gcloud
. 하지만 Python 셸을 열면 어떤 일이 일어나는지 살펴보세요.
>>> 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
어딘가에 저장된 사용자 인증 정보를 사용하여 Python SDK를 통해 Google Cloud에 계속 액세스할 수 있습니다. 방법이 있나요?완전히내 노트북에서 Google Cloud를 로그아웃하시겠습니까?
편집: 더 명확히 하기 위해: 이 컴퓨터에는 Google 클라우드 서비스 계정 JSON 파일이 저장되어 있지 않으며 GOOGLE_APPLICATION_CREDENTIALS
환경 변수를 설정 해제했습니다.
답변1
이것이 어떤 식으로든 도움이 될지는 모르겠지만 비슷한 문제가 발생했습니다. 명령을 사용하여 모든 자격 증명을 취소한 후에도 gcloud auth revoke --all
여전히 내 환경에 대해 스크립트를 실행할 수 있었습니다. 결국 나는 응용 프로그램 기본 자격 증명 파일을 찾았습니다.~/.config/gcloud/application_default_credentials.json. 이 파일의 이름을 바꾸거나 삭제하면 자격 증명이 완전히 취소되는 데 도움이 되었습니다. 이제 클라이언트 라이브러리는 환경에 액세스할 수 없습니다.
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