Como faço para sair completamente do Google Cloud? `gcloud auth revoke --all` não resolve

Como faço para sair completamente do Google Cloud? `gcloud auth revoke --all` não resolve

Saindo do Google Cloudparececomo se fosse fácil. Se eu correr:

$ 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`

A princípiovisualcomo se eu estivesse completamente desconectado gcloud. Mas veja o que acontece quando abro um shell 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!"

Como você pode ver, mesmo depois de executar, gcloud auth revoke --allainda consigo acessar o Google Cloud por meio do Python SDK usando credenciais de usuário armazenadas em algum lugar. Existe uma maneira decompletamentesair do Google Cloud no meu laptop?

EDIT: para esclarecer melhor: não há nenhum arquivo JSON da conta do Google Cloud Service salvo neste computador e desativei a GOOGLE_APPLICATION_CREDENTIALSvariável de ambiente.

Responder1

Não tenho certeza se isso irá ajudá-lo de alguma forma, mas me deparei com um problema semelhante. Depois de revogar todas as credenciais usando o comando, gcloud auth revoke --allainda consegui executar scripts em meu ambiente. No final, encontrei o arquivo de credenciais padrão do aplicativo localizado em~/.config/gcloud/application_default_credentials.json. Renomear ou excluir este arquivo ajudou a revogar completamente as credenciais. E agora a biblioteca cliente não tem acesso ao ambiente:

  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

Responder2

Como comentado acima porAjahn Charles, gcloud auth application-default revokefunciona. Basta clicar no comando e ele removerá as application-defaultcredenciais. Veja a diferençaaqui. Eu tive o mesmo problema e só isso funcionou.

Editar:

Lembre-se de que você ainda precisa ligar, gcloud auth revoke --allpois gcloud auth application-default revokeapenas remove os créditos padrão do aplicativo.

informação relacionada