Kim Seungha
Kim Seungha

Reputation: 29

`gcloud source repos clone` with service account is not working

Deploying my personal project to GCE(Google Compute Engine), I tried to clone a git repo in Google Cloud Platform. But it did not work. I guess git repo in GCP uses code.google.com internally, and that is not compatible with service accounts. It prints

Cloning into '/home/...'...
fatal: remote error: Invalid username/password.
You may need to use your generated googlecode.com password; see https://code.google.com/hosting/settings
ERROR: (gcloud.source.repos.clone) Command '['git', 'clone', 'https://source.developers.google.com/p/.../r/...', '/home/...', '--config', 'credential.helper="gcloud.sh"']' returned non-zero exit status 128

Currently logged in [email protected] and image is Debian (GCE default)

Upvotes: 3

Views: 2537

Answers (1)

cherba
cherba

Reputation: 8980

How was your GCE instance created?

You need to make sure it has https://www.googleapis.com/auth/source.full_control scope. To list scopes you can run

gcloud compute instances describe INSTANCE_NAME \
    --zone=INSTANCE_ZON --format="yaml(serviceAccounts)"

If you used gcloud command to create the instance you can use --scopes flag to include the source scope.

Alternatively if you use developer console to create the GCE instance make sure to select "Allow full access to all Cloud APIs" in "Service account" section.

Upvotes: 1

Related Questions