libgit2 / libgit2/pygit2

_pygit2.GitError: authentication required but no callback set

Open
#782 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

support
Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

I'm guessing this is an issue on my end, not really an issue with pygit2, but I've been stuck on it for two days with almost no progress and the documentation isn't making sense to me.

I am trying to push to a repository using user name and password credentials and getting the error:

File "createRepo.py", line 72, in remote.push(['refs/heads/master']) File "/usr/local/lib/python2.7/dist-packages/pygit2/remote.py", line 470, in push check_error(err) File "/usr/local/lib/python2.7/dist-packages/pygit2/errors.py", line 64, in check_error raise GitError(message) _pygit2.GitError: authentication required but no callback set

```
#Clone the newly created repo
repoClone = pygit2.clone_repository(repo.git_url, '/var/www/html/uploads/tmp')
print "GIT URL: "
print repo.clone_url
print "<---"

#Add the new files to the repo
for file in files:
    os.rename("/var/www/html/uploads/" + file, "/var/www/html/uploads/tmp/" + file)

#Commit it
repoClone.remotes.set_url("origin", repo.clone_url)
index = repoClone.index
index.add_all()
index.write()
author = pygit2.Signature("MaslowCommunityGardenRobot", "info@maslowcnc.com")
commiter = pygit2.Signature("MaslowCommunityGardenRobot", "info@maslowcnc.com")
tree = index.write_tree()
oid = repoClone.create_commit('refs/heads/master', author, commiter, "init commit",tree,[repoClone.head.get_object().hex])
remote = repoClone.remotes["origin"]
credentials = pygit2.UserPass(userName, password)
remote.credentials = credentials
remote.push(['refs/heads/master'])

The documentation clearly says that there is an optional callback argument push(specs, callbacks=None), but how and when to use that feature is not clear.

If I can get this to work I will post it as a clear, simple example of how to create a repository with pyGitHub, clone it, create a commit, and push it which is something I think is missing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with createRepo.py around line 72 and the pygit2 remote.push(specs, callbacks=None) documentation, then compare the UserPass assignment with the callback API. Determine whether the authentication guidance or example is missing, and consider the issue done when the required push authentication flow is clearly documented or demonstrated.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
authentication, backend
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.