This applies to such use cases where using a personal account is not an option. For example to run a cronjob in a remote server.
my-account@my-project.iam.gserviceaccount.com is the service account email and my-account-key.json is the key file for this example.gcloud auth activate-service-account --key-file=my-account-key.json
gcloud config set account my-account@my-project.iam.gserviceaccount.com