87

I am part of an organization that uses SSO in Github. I don't have problem to access the repository through the web, it redirects me to SSO login and that's all.

The problem started when I logged-in first to my personal repository on GitHub through Git-Bash, I did some changes and then I wanted to do changes in a repository from my organization. When I run the below command, it wrote me that I need to re-authorize the OAuth Application, but I don't understand how:

$ git push --delete origin v0.1.3
remote: The `<my_company>' organization has enabled or enforced SAML SSO. To access
remote: this repository, you must re-authorize the OAuth Application `Git Credential Manager`.
fatal: unable to access 'https://github.com/<my_company>/myproj.git/': The requested URL returned error: 403

How can I re-authorize the login?

I tried to re-open Git-Bash but it wrote me the same error.

E235
  • 11,560
  • 24
  • 91
  • 141
  • 1
    If you have "you must re-authorize the ... 'Visual Studio'", then you'll need to remove Visual Studio from your settings here https://github.com/settings/applications, as well as follow the steps below. – thegoodhunter-9115 Jan 24 '23 at 21:19

7 Answers7

103

My company just enabled SSO for my Github Org overnight so was getting the same error running git pull. I fixed this with the following steps.

  1. Open Credential Manager in Windows and delete the existing credential for github.com
  2. Re-initialise the cred manager in git bash: git config --global credential.helper manager-core
  3. Re-run git pull and follow the pop-up instructions to authenticate in a browser (which happened automatically for me with SSO).

After those steps git commands worked for me again.

pmckeown
  • 3,419
  • 3
  • 31
  • 35
62

I used the Github cli by running the following in the terminal

gh auth login

which then prompted me to re-authenticate, and I was able to.

If you do not have the CLI (Command Line Interface) currently installed, you can visit https://cli.github.com/ for more information. There is a download for Mac.

JGallardo
  • 11,074
  • 10
  • 82
  • 96
jmazin
  • 1,021
  • 9
  • 11
  • I saw this reauthorization error after my organization enabled SSO for GitHub Enterprise. This solution worked well for me. When it was complete, I could use the `git` CLI again. When this authN process was running, it prompted me for "GHE hostname". I didn't know what to put, so I just entered "github.com". That turned out to be what I needed. – Mr. Lance E Sloan Jul 22 '22 at 15:18
  • This is the easiest and best way of fixing the issue. – Mahmut C Sep 02 '22 at 11:13
  • Note that using `gh auth login` is technically separate from using git credential manager core for authorization. It works, but it uses a different credential management solution (oauth token). – Josh Johanning Mar 21 '23 at 15:15
22

For VSCode users or any other IDE you need to force GitHub to re-authorize the app!

  1. Go to your settings on GitHub.com -> Applications -> Authorized OAuth Apps - https://github.com/settings/applications
  2. Search for "GitHub for VSCode"
  3. Choose "Revoke" from the "..." menu.

If you then sign out in VSCode and sign in again, you should be prompted to re-authorized.

BigBlueHat
  • 2,355
  • 25
  • 30
eliarms
  • 551
  • 4
  • 6
18

Delete git from "credential manager" window's application. Then pull on repo again. The sso authentication should automatically come up.

Aaron J
  • 341
  • 2
  • 8
  • 1
    To clarify, on mac, you can go to the "Keychain Access" app and delete any `git:` login credentials to re-force the git credential manager core login for GitHub. – Josh Johanning Mar 21 '23 at 15:14
6

This works for me by revoking the current application in the Github Settings > Settings > Applications > Authorized OAuth Apps

and then try the git pull again.

Player1
  • 2,878
  • 2
  • 26
  • 38
5

For Visual Studio 2022, Click your profile icon, select Account Settings and then remove and re-add your GitHub credentials

BeanFlicker
  • 503
  • 1
  • 9
  • 23
0

In Visual studio code, click on profile icon and signout of git. Then login to github, go to settings > Applications > Authorized Oauth Apps. Revoke "VS code" and "Windows Credentials Manager".

In Windows, search for "Credentials Manager" app and delete "git:".

Now clone freshly from VS code and terminal(git clone). Authorize from browser in github. Now, you will re-authorized in both VS Code and command line.

Karthik C
  • 44
  • 2