question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when pushing using personal access token -- the requested URL returned error: 403

See original GitHub issue

Context: Was checking out multiple private repos and was copying a file from a private repos to a public repos in the workspace, then committing and pushing. The push would fail with a 403.

Error:

remote: Permission to my-repos denied to github-actions[bot].
fatal: unable to access 'https://github.com/.../my-repos.git/': The requested URL returned error: 403

By running this command we can see any of config settings being used for our repos:

git config -l

We discovered the checkout action is executing a command like this:

git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***

Reference: https://github.com/actions/checkout/blob/master/adrs/0153-checkout-v2.md#pat

The fix is to do this:

git config --local --unset-all "http.https://github.com/.extraheader"

It’s seems unlikely that this could lead to side effects but it may be desirable to re-set this value after the push is completed.

Sorry for lack of PR, we ended up not using your action and just incorporated what we ended into our workflow file.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
xianshenglucommented, Apr 30, 2022

For me, I used permissions: write-all to make it work with my custom git push command.

on:
  push:
    branches:
      - dev

permissions: write-all

jobs:
0reactions
ftheetencommented, Sep 10, 2021

Using the standalone and cross-platform “GCM” (Git Credential Manager) indirectly solved this problem for me (on a Windows 1O platform)

I installed it from this resource : https://github.com/microsoft/Git-Credential-Manager-Core/releases/tag/v2.0.498

(https://github.com/microsoft/Git-Credential-Manager-Core)

Once it is installed, the first push operation (or pull) displays a prompt allowing to reach the remote GitHub. It didn’t work well with the Personal Access Token, but this tool also allows to open the GitHub HTML page, by providing the “classic” username and password. It apparently stores the credentials in a cache. Commits and pushes both work with the Bash console and TortoiseGit. I’m not sure what happens when the token expires though…

Read more comments on GitHub >

github_iconTop Results From Across the Web

git - GitHub's personal access token not working?
I have tried everything mentioned in this thread: Pushing to Git returning Error Code 403 fatal: HTTP request failed.
Read more >
Solving Github Password Authentication 403 Errors
Generating A Personal Access Token On Github. This is the easy part. Simply go to the following URL : https://github.com/settings/tokens, and ...
Read more >
Sourcetree ignores github token and throws 403 error
To prevent this after removing the old git credentials, delete Atlassian folder from all the appdata folders. Then go to Tools->Settings->Authentication and add ......
Read more >
Pushing to Git returning Error Code 403 fatal: HTTP request ...
Note that 403 means is an HTTP code that means forbidden. It implies that your URL exists, the server is working, but there...
Read more >
Can't push to your GitHub repo? I can help with that.
Please use a personal access token instead. fatal: unable to access <git_repo>: The requested URL returned error: 403.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found