Here’s the command to authenticate as a service account.

<pre lang="bash">
gcloud auth activate-service-account --key-file=key.json

To log out.

<pre lang="bash">
gcloud auth revoke