12

I've encountered a recent problem, it applies to any new GitHub organisations I create.

I am admin for two fairly mature GitHub organisations. I can create repos within them, and everything "just works". (SmartGit, & CLI Git, OSX).

But, if I create a new organisation, I can't Push to it, I get a 403 error:

$ git push 
remote: Permission to [org]/[repo].git denied to [username].
fatal: unable to access 'https://github.com/[org]/[repo].git/': 
  The requested URL returned error: 403
$

Steps to reproduce:

  1. create organisation
  2. create repo within organisation
  3. make text edit via GitHub
  4. clone repo
  5. make text change
  6. add/commit/push > 403 error reported

I can make (& commit) changes via the GitHub.com web-page interface, but I can't push them from my local repo.

Note: From a different PC I can push to repos in existing organisations, but not the new ones. The other PC was still a Mac though, so it may be keychain related. Ok, I've tested it from a Windows VM, and it still fails. So, it does look like something at the GitHub end.

Any suggestions?

ianmayo
  • 2,256
  • 3
  • 26
  • 44
  • 1
    can you check `git remote -v` has listed your expected repository ? – Shakil Feb 27 '19 at 12:40
  • Yes, it exactly matches the `https://github.com/[org]/[repo].git` value given in the `Clone with HTTPS` panel. – ianmayo Feb 27 '19 at 12:47
  • 1
    Noticed that the `git push` didn't ask for the username & password, this leds me to a question I recently seen, who is also using OS X, that is receiving 401 and found nowhere to modify his GitHub token. At the end he found it is located in the password keyring (something similar, I don't have an OS X), and solved by editing it. I am not sure if this can help you, if you have 2 accounts and mixed them, for example. – Geno Chen Mar 01 '19 at 15:44
  • Thanks for that suggestion Geno. No, I just have one GitHub account, and I can push to repos in other organisations from the CLI. It may be OSX Keychain related in some way, though I don't know why it's ok with legacy organisations & not new ones. – ianmayo Mar 01 '19 at 18:45
  • 1
    Have you tried deleting the github.com entries from your keychain? Applications -> Utilties -> Keychain Access and search for github.com and delete. Then retry to see if it makes difference. Worst case - you will just add them again and nothing will be lost. – hovanessyan Mar 02 '19 at 13:03
  • Thanks for the +hovanessyan . I've just tested it from a MS Windows VM - so it does look like it's at the GitHub end. – ianmayo Mar 02 '19 at 13:42
  • 1
    Just an idea: Try using command line in Terminal, clone using ssh instead of https, tweak, push, all at the command line, see if that works. – matt Mar 02 '19 at 13:50
  • 1
    Also please read thru all of https://stackoverflow.com/questions/5335197/gits-famous-error-permission-to-git-denied-to-user as there might be something applicable. – matt Mar 02 '19 at 13:54

3 Answers3

9

I installed GitKraken in a VM and in the GitHub authorisation process I had to indicate when organisations it could access. The new repo had a red Cross against it. I selected it, to allow GitKraken access to that organisation. GitKraken was then able to push to the new repo.

I then received an email telling me the GitHub authorisation had been added. It included a link to this page https://github.com/settings/connections/applications/

From that page I was able to view authorised OAuth apps. SmartGit (my normal Git client was listed). When I went into the page for that app, I saw it wasn't allowed access to my new organisation. I authorised access.

From that point on, I was able to push from either SmartGit or the command-line.

fosslinux
  • 109
  • 1
  • 6
ianmayo
  • 2,256
  • 3
  • 26
  • 44
3

I had the same issue with SourceTree.

HTTP Error Code 403 and no access, but using GitHub.com (web) worked without any issues. As pointed out already, the third party application has no access.

Ensure that your Organization has the third-party app approved (SourceTree, GitKraken, etc.) https://github.com/organizations/%ORGANIZATION_NAME%/settings/oauth_application_policy

Third-party access on organization

  • You can approve the app by first connecting it with your account and then going to https://github.com/settings/connections/applications/
  • From there, click on the name (link) and the application detailsv will be shown. -At the bottom, you'll see your Organizations and you can approve it ❤️
Delta
  • 721
  • 8
  • 5
-1

Basically it's better to make a pull request instead of pushing code to organization.

If you wants to push little bit of code or tags without caring about ssh or token, you can use GitKraken (only works one of my 2 PCs) or Github desktop (It's no reason it cannot work)

andy840119
  • 54
  • 4