Logging out of Google Cloud seems like it should be easy. If I run:
$ 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`
It at first looks like I'm completely logged out of gcloud
. But watch what happens when I open a Python shell:
>>> 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!"
As you can see, even though I ran gcloud auth revoke --all
I'm still able to access Google Cloud through the Python SDK using user credentials that are stored somewhere. Is there a way to completely logout of Google Cloud on my laptop?
EDIT: to clarify further: there aren't any Google Cloud Service account JSON files saved on this computer, and I've unset the GOOGLE_APPLICATION_CREDENTIALS
environment variable.
I'm not sure if this will help you in any way but I ran into a similar issue. Once I had revoked the all credentials using the command "gcloud auth revoke --all" I was still able the execute scripts against my environment. In the end, I found the application default credentials file locating in ~/.config/gcloud/application_default_credentials.json. Renaming / Deleting this file help to remove the client library's ability to the authentication. I no get the follow
As commented above by AjahnCharles,
gcloud auth application-default revoke
works. Just hit the command and it will remove theapplication-default
creds. See the difference here. I had the same problem and only this worked.Edit:
Remember that you still need to call
gcloud auth revoke --all
asgcloud auth application-default revoke
only removes the application-default creds.