Difficulty Authenticating Via Service Account

646 views
Skip to first unread message

Josh Andrews

unread,
Jan 18, 2017, 3:44:20 PM1/18/17
to Google Cloud Developers
Hello Google Cloud Devs --

I have been sent a .p12 file for authenticating via a Google Cloud service account.

I've already previously authenticated via OAuth2. When I try to run the "gsutil config -e" command to give it the e-mail address and .p12 file as documented here (under "Configuring Service Account Credentials"): https://cloud.google.com/storage/docs/gsutil/commands/config

I receive this message and am redirected to a web browser to authenticate via OAuth2 again:

"CommandException: OAuth2 is the preferred authentication mechanism with the Cloud SDK. Run "gcloud auth login" to configure authentication, unless you want to authenticate with an HMAC access key and secret, in which case run "gsutil config -a".

I do not want to authenticate with an HMAC access key and secret, so "gsutil config -a" does not help.

Can anyone provide some guidance on the command necessary to configure authentication via a service account?

Thanks,

Josh

Alex (Cloud Platform Support)

unread,
Jan 20, 2017, 3:51:35 PM1/20/17
to Google Cloud Developers

Hi Josh,


Just to make sure, you are doing this to authenticating on behalf of a service or application (as opposed to a user) as documented in Configuring Service Account Credentials?

In this case, you would first need to activate the service account running the command “gcloud auth activate-service-account --key-file [KEY_FILE]” as described in the Authorizing with a service account guide.


However, if you are only looking to use Cloud SDK tools from the command line on a single machine, you can enable them by running the “gcloud init” command and follow the Authorizing with a user account guide.


Let me know if those guides help you and if not, make sure to include additional details of what you are trying to achieve.


Cheers!

Alex

Reply all
Reply to author
Forward
0 new messages