How to resolve "refusing to allow an OAuth App to create or update workflow" on git push

GitGithubGithub Actions

Git Problem Overview


Getting > refusing to allow an OAuth App to create or update workflow .github/workflows/cd.yml without workflow scope"

on git push. How to grant workflow scope?

Git Solutions


Solution 1 - Git

I've literally just come across this problem when trying to use IntelliJ to push to a branch that contains a GitHub Action workflow (YAML file in .github/workflows). I didn't find existing resources on the Internet very helpful, so I hope this will help you fix it too.

TL;DR: Generate a new Personal Access Token with the workflow scope enabled in GitHub and configure your application to use that.

Background: third-party tools with GitHub integrations like IntelliJ, Visual Studio Code, Github Desktop, etc use tokens to connect to your GitHub account so they can pull/push, etc on your behalf. In the case of IntelliJ, their instructions only say to include the repo, the gist, and the read:org scopes. But you need the workflow scope to modify GitHub Actions.

Here's how to fix it:

  1. In your Github account, go to Settings (in your avatar dropdown in the top right-hand corner)
  2. Go to Developer Settings > Personal Access Tokens
  3. If your application is listed, click on its name to edit the settings associated with its token. Make sure workflow is ticked.
  4. Click on Update Token to save the change.
  5. On the same page, click on Generate Token. Read the information carefully, then click OK to continue.
  6. Copy the new token that Github shows you.
  7. You will need to recreate your application's integration with Github using the new token for the change to take effect.

Note: you may be able to skip steps 5 onward if your application refreshes its permissions automatically, but that didn't seem to work for me with IntelliJ.

In IntelliJ, the last step was to go to Settings > Version Control > GitHub, then remove the existing integration and re-add it, pasting in the new token. You'll have to find out what needs to be done for the tool you're using to give it the new GitHub Personal Access Token.

Solution 2 - Git

For Windows 10: Go to Settings -> Credentials Manager -> Windows Credentials -> Remove github.com credentials -> git pull/push your github project from git-bash console -> Reconnect GitHub Account in your IDE/Source control. You don't need create Personal Access Token with "workflow", you don';t need create secret GITHUB_TOKEN (it creates auto and can't created manual)

Solution 3 - Git

Running macOS Big Sur. I am pushing my .yml workflow file from the Atom text editor and this worked for me.

  1. Go to github personal access tokens settings and generate a new token. Make sure you select both repo and workflow access scope.
  2. Go to Keychain Access app on Mac, and search for github. I found an entry (shown below) named github.com, of Internet password kind, which was previously filled with a seemingly random token. Replace the password entry with the generated token (the one begins with ghp_) from step 1.

2

Solution 4 - Git

This issue also happens simply because your current token is not allowed to work with workflow on Github. Do the following steps to fix

For people using Android Studio on MacOS:

  1. Delete your current token (Preferences -> Version Control -> GitHub): enter image description here

remember to hit the "Ok" button.

  1. Try to push/pull again from Android Studio, an popup now will appear. enter image description here

  2. Hit Use Token... button, another popup will appear. enter image description here

  3. Click on Generate, you will be sent to GitHub website to generate a new token. Remember to select the workflow permission. enter image description here

  4. Click generate Button to get a new token and paste it to Android Studio in step 3. It's all set now.

Solution 5 - Git

In my case, I had stale GitHub credentials in macOS Keychain. I was modifying a workflows file and pushing the changes from the command line, hence I didn't think of checking the Keychain at all. The Updating credentials from the macOS Keychain explained how to use git credential-osxkeychain to erase the Keychain:

$ git credential-osxkeychain erase
host=github.com
protocol=https
> [Press Return]

I then had to enter my username and password again. This time I generated a new personal access token and used that token for the password. Then I could finally push the workflows changes.

Solution 6 - Git

On Windows 10 Here is step by step how I was able to fix the issue

I've included lots of screenshots `cause this was way harder to resolve then it should have been.

In hind sight, what @CSRedRat said is right but as I was having the problem I couldn't understand that because the answer was so terse.

Ultimately what led me to the solution was this article which makes the situation more clear.

Here's the deal. While you can work around this issue using the GitHub Developer Settings Menu to generate a new token and then pasting that into the Windows Credential Manager, you shouldn't because eventually that token will expire and then you will be having this issue again since nothing will know how to refresh the token since you set it manually.

Instead, this token privs issue needs fixed via Git for Windows. So the deal is the "old" Git Credential Manager for Windows didn't ask for privs to create or update workflows but now you need them. The good news is there is a new version our called Git Credential Manager Core and it does ask for these privs and more.

The new credential manager ships with Git 2.28 and later, but isn't enabled by default. If you already have Git for Window of this version or later installed then you already have the software even. In my case I had version 2.30.2 so I already had the new software.

enter image description here

But it was still using my old Git for Windows credentials which don't carry the privs needed. That may be your case as well or if you don't have a version older 2.28 then you need to first install a newer version. Either way, once you have a new enough version of Git for Windows on your machine the next step is to remove the old credentials by typing "windows credential manager" in the windows search box.

enter image description here

Then find each git credential, click on it and click the remove button.

enter image description here

Now next time you try to access your get account from git bash Visual Studio or whatever git client you use, you will be prompted for new credentials because the old ones are gone. Click the Sign in with your browser button in the dialog below:

enter image description here

Then you will see a web page like this one below, and if you expand the workflow drop down you will see it is asking for the privs you need this time. Then click Authorize button.

enter image description here

Once you do that, you will see a page like this for providing your github password:

enter image description here

Now you have a new credential in your windows credential manager that has the privs you need and your operation that use to fail will now succeed. Yea!

Solution 7 - Git

Fixed this by using the Desktop Github App for pushing my changes (it seems to have full permissions vs. the limited scope of vs code).

After getting that one commit with the modified workflow file pushed through, I was able to make push commits normally again in vs code.

Solution 8 - Git

I had this issue with CLion 2020.2.3 while attempting to push a change to .\github\workflows\build.yml. CLion appears to use the "JetBrains IDE Integration" token (GitHub Settings -> Applications -> Authorized OAuth Apps) which does not include the "workflow" scope. There does not appear to be a way to change the scope of this token.

I created a new Personal Access Token with the correct permissions (GitHub Settings -> Developer settings -> Personal access tokens -> Generate new token), but I was unable to configure CLion to use it.

Ultimately I was able to push the commit using GitHub Desktop instead.

Solution 9 - Git

This happened to me on GitKraken. I simply disconnected and reconnected GitHub from GitKraken and it worked.

Solution 10 - Git

I followed this article to install Git Credential Manager Core to handle this automatically - and it works well for me (macOS):

Using homebrew:

brew tap microsoft/git
brew install --cask git-credential-manager-core

Solution 11 - Git

I had to upgrade my Git For Windows to version 2.29.2.2. That allowed the git command line to sign in through the browser, which GitHub now requires.

I did this after trying a Windows Credential Manager reset and regenerating my Personal Access Token, which didn't resolve it. But it did cause GitHub to send me an email like this:

> [GitHub] Action required - Password authentication in Git for Windows is no longer supported > > We have detected that you recently attempted to authenticate to GitHub using an older version of Git for Windows. GitHub has changed how users authenticate when using Git for Windows, and now requires the use of a web browser to authenticate to GitHub. To be able to login via web browser, users need to update to the latest version of Git for Windows.

Solution 12 - Git

This happened to me on PHPStorm. I was trying to use the IDE to commit and push my alterations, so when i got the error, i tried to push with command line on IDE console and i got it.

Solution 13 - Git

For IntelliJ IDE users, follow these simple steps:

  1. Go to Files > Settings > Version Control > Github and remove the Github account by clicking on the account and then on the '-' button.
  2. Then Sign in to Github.com in your default browser & then click on the '+' button on the same IDE window we opened in step 1. Then select 'Login with token'.
  3. Click on the Generate Button.
  4. This will open a GitHub page in your browser with all the permission prefilled. All you have to do is click on 'Generate Token' at the bottom of the page. Then use that token to fill it in the IDE pop-up window.
  5. Close the settings window & push your code again. This always works for me.

Solution 14 - Git

You also can change from using https to using SSH.

  1. Create your SSH key, you can follow the docs.
  2. Change your remote from https to SSH, also you can follow the docs.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAra YeressianView Question on Stackoverflow
Solution 1 - GitEmma BurrowsView Answer on Stackoverflow
Solution 2 - GitCSRedRatView Answer on Stackoverflow
Solution 3 - GitDiegoView Answer on Stackoverflow
Solution 4 - GitThaiPDView Answer on Stackoverflow
Solution 5 - GiteirikvaaView Answer on Stackoverflow
Solution 6 - GitRonCView Answer on Stackoverflow
Solution 7 - GitAerodynamicView Answer on Stackoverflow
Solution 8 - GitBrandon GroomView Answer on Stackoverflow
Solution 9 - GitPhilView Answer on Stackoverflow
Solution 10 - GitfuguView Answer on Stackoverflow
Solution 11 - GitBill MeneesView Answer on Stackoverflow
Solution 12 - GitIgor MacedoView Answer on Stackoverflow
Solution 13 - GitGmacvView Answer on Stackoverflow
Solution 14 - GitEsemegaView Answer on Stackoverflow