I've been using Google source repos for many years, and now I'm getting permission denied when I try to push or pull.
I've checked everything I can think of:
- Updated gcloud:
gcloud components update - Reinitialized:
gcloud init - Reinstalled gcloud tools
- Updated git
- Cloned repo to new directory (no permission)
- I still have access on the console: https://source.cloud.google.com/project/default
- Closed and reopened terminal
- I'm the owner of the organization and the project but I also added all source repository permissions
The above process sets my account and project so those are all set.
I just tried on a different computer (Windows 10), and I don't get permission denied. The issue has something to do with my Mac setup...
Below are some examples:
$ git pull
remote: PERMISSION_DENIED: The caller does not have permission
remote: [type.googleapis.com/google.rpc.RequestInfo]
remote: request_id: "xxx"
fatal: unable to access 'https://source.developers.google.com/p/project/r/default/': The requested URL returned error: 403
$ gcloud source repos clone default --project=project
Cloning into '/Users/user/TMP/default'...
remote: PERMISSION_DENIED: The caller does not have permission
remote: [type.googleapis.com/google.rpc.RequestInfo]
remote: request_id: "xxx"
fatal: unable to access 'https://source.developers.google.com/p/project/r/default/': The requested URL returned error: 403
ERROR: (gcloud.source.repos.clone) Command '['git', 'clone', 'https://source.developers.google.com/p/project/r/default', '/Users/user/TMP/default', '--config', 'credential.https://source.developers.google.com/.helper=', '--config', 'credential.https://source.developers.google.com/.helper=!gcloud auth git-helper [email protected] --ignore-unknown $@']' returned non-zero exit status 128.
$ git clone ssh://[email protected]@source.developers.google.com:2022/p/project/r/default
Cloning into 'default'...
[email protected]@source.developers.google.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The first you can do is check the repository details and check the
access leveland the acces need to be set towriteThen go to tools -> Options and Authentication and delete all the passwords under
git saved passwordor you could use the following commands:git config --system -lYou will get,
credential.helper=!github --credentialsAnd then use
git config --system --unset credential.helperto remove the saved credentials (make sure you run this as an admin)More on the subject on removing the credentials refer to this link
If removing the credentials doesn't work, here is another link to help you with the 403 error using the SSH or modifying the HTTPS URL