E235
E235

Reputation: 13500

How to re-authorize the OAuth Application 'Git Credential Manager'

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.

Upvotes: 141

Views: 203010

Answers (12)

einnocent
einnocent

Reputation: 3984

All I needed to do was

gh auth refresh

when I got the broadly similar message:

remote: To access this repository, you must re-authorize the OAuth Application 'GitHub CLI'.

Upvotes: 2

Gon&#231;alo Peres
Gon&#231;alo Peres

Reputation: 13602

On Windows, accessed Credential Manager (on Mac should be Keychain Access)

enter image description here

Then, in Windows Credentials, removed all that started with git:

enter image description here

With that, after running git fetch in Git Bash in the same directory, this opened up (I have GitHub CLI installed - it might be required)

enter image description here

Then clicked Sign in with your browser (if one's default browser is not the one we are logged in, copy the URL, close the tab, and paste the URL in the browser one is logged in).

Now one should be able to interact without any problem.

And if one checks the Mredential Manager, one should see a new one in Windows Credentials (one might have to click "Web Credentials" then click back "Windows Credentials").

Upvotes: 4

Jens Berger
Jens Berger

Reputation: 314

At least on Windows, it worked for me to simply trigger re-authentication using git credential-manager github login.

Upvotes: 8

TWiStErRob
TWiStErRob

Reputation: 46480

I had this problem on a Mac. The solution was to re-authenticate with GitHub:

$(git config --global credential.helper) github login

Upvotes: 3

PradeepKN
PradeepKN

Reputation: 667

In my case Authorisation was revoked and access was given back. Now, Organisation authorisation was missing.

To enable it back, Follow the steps •

  1. Github Profile
  2. Settings
  3. Developer Settings
  4. Select Personal access token
  5. Delete existing token and generate new token under Tokens (classic)
  6. Copy the new token created.
  7. Click on Configure SSO arrow under generated token. You will see your organisation and it might display Authorise.
  8. Click on Authorise. It should turn into Deauthorise in red.

After all this step open your terminal or command line tool

run below commands brew install gh (if gh is not installed) gh auth login

Follow the instruction and select https if you already cloned using https.

That's it. Happy coding :)

Upvotes: 1

Karthik C
Karthik C

Reputation: 44

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.

Upvotes: 0

eliarms
eliarms

Reputation: 859

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.

Upvotes: 35

Flatly-stacked
Flatly-stacked

Reputation: 649

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

Upvotes: 14

Player1
Player1

Reputation: 3205

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.

Upvotes: 6

jmazin
jmazin

Reputation: 1377

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.

Upvotes: 95

Aaron J
Aaron J

Reputation: 389

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

Upvotes: 23

pmckeown
pmckeown

Reputation: 4209

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.

Upvotes: 170

Related Questions