'gcloud auth activate-service-account logout / revoke / remove / unset

I,ve added my service-account successfuly using below command.

gcloud auth activate-service-account --key-file=mycredentialsialreadyhad.json

Now I can't remove or logout from it.

any help would be greatly appreciated.

edit: i tried this commands and got error

  1. gcloud auth revoke

ERROR: (gcloud.auth.revoke) Cannot revoke GCE-provided credentials.

  1. gcloud config configurations delete default

ERROR: (gcloud.config.configurations.delete) Deleting named configuration failed because configuration [default] is set as active. Use gcloud config configurations activate to change the active configuration.

edit2: this gcloud cli is on GCP ubuntu VM



Solution 1:[1]

UPDATE

Try a command with a specified account because you can't revoke the Compute Engine service account(default).

For example:

gcloud auth revoke [email protected]

and run:

gcloud auth list

It should only display the default service account:

[PROJECT-NUMBER][email protected]

Solution 2:[2]

Use the below syntax to activate the service account. Here we need to mention service account ID. gcloud auth activate-service-account [email protected] --key-file=xxxxxx.json --project=xxxxxx

Use the below syntax to revoke the service account: gcloud auth revoke [email protected]
Error encountered in your case because the service account ID was not mentioned in gcloud auth revoke command , which is trying to revoke your active google account.

Permissions are denied if you disable the service account instead of revoke. If you revoke the service account then default account will get activated and that might have permission to storage.

Solution 3:[3]

TLDR; To logout from all accounts

gcloud auth revoke --all

To check active account logins

gcloud auth list

To logout form one account only (take account from command above)

gcloud auth revoke [ACCOUNT]

Solution 4:[4]

this error happens when you try to remove a service account that was propagated to the machine during the creation time (docs here). this service account could not be removed from your machine.

in any other case, the following commands should work (as mentioned in other answers here).

gcloud auth revoke --all

OR

gcloud auth revoke [ACCOUNT]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 matson kepson
Solution 4 eli sharf