Pygithub: get_repo sends 404 for repos from organizations

Created on 6 Mar 2017  ·  7Comments  ·  Source: PyGithub/PyGithub

Hi,

I'm having trouble calling get_repo with the name of a repo I have access to in an organization.

Here's what I simply do:

repo = me.get_user().get_repo(name_of_organization_repo_i_have_access_to)

This is what I get:
github.GithubException.UnknownObjectException: 404 {'documentation_url': 'https://developer.github.com/v3', 'message': 'Not Found'}
It works fine with a repo associated to my own account. But as soon as I need one from an organization it fails.

What is strange to me is that:

repos = me.get_user().get_repos()

Shows the repo in the list as expected.

Am I missing something obvious?

Most helpful comment

@mlainez Actually, looks like we should be using the get_repo() method on the main class. So it would be:

>> g = Github("user", "password")
>> repo = g.get_repo("Org/RepoName", lazy=False)
>> repo 
Repository(full_name="Org/RepoName")

All 7 comments

+1 I am having the same issue. The problem is that this line sets the user to be the authenticated user explicitly. I can't seem to find another method in the API that allows us access to the repo by full name.

https://github.com/PyGithub/PyGithub/blob/master/github/AuthenticatedUser.py#L851

@mlainez Actually, looks like we should be using the get_repo() method on the main class. So it would be:

>> g = Github("user", "password")
>> repo = g.get_repo("Org/RepoName", lazy=False)
>> repo 
Repository(full_name="Org/RepoName")

I will probably add this to some example usage page.

I'm trying @RichardJTorres's solution, but still get a 404. Can access non private repos, but not organization repos.

Ah, the problem was that I hadn't given the token the right permissions. Clear.

Ah, the problem was that I hadn't given the token the right permissions. Clear.

@PedroGFonseca do you remember what permissions the token needed for this? I'm experiencing the same issue.

@thecturner It works for me with the repo scope.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rthill91 picture rthill91  ·  4Comments

rpocase picture rpocase  ·  5Comments

AdyaAbhra picture AdyaAbhra  ·  5Comments

PeterJCLaw picture PeterJCLaw  ·  6Comments

nchammas picture nchammas  ·  3Comments