2

I want to access a private repository of a team that I am part of. However, I am not able to access it. It throws an exception as follows:

UnknownObjectException: 404 {u'documentation_url': u'https://developer.github.com/v3/repos/#list-teams', u'message': u'Not Found'}

My code:

from github import Github
import pandas as pd


git = Github("token")
org = git.get_organization('org')

org.get_repo('repo_name')

It throws n error at the above statement.

I want to access this repository and get the count of number of teams who have access to the repository. However, I got the above mentioned error at the last line of the above code.

Can someone help me to fix this?

Tjs01
  • 457
  • 2
  • 8
  • 14
  • I guess both of it does the same thing if my understanding of what you said is correct. However, I tried what you said but didn't work :-( – Tjs01 Jan 10 '19 at 16:53

3 Answers3

3

For Github Enterprise:

from github import Github  

g = Github(base_url="https://your_host_name/api/v3", login_or_token="your_access_token") 
org = g.get_organization("your_org")  
repo = org.get_repo(repo_name)   # getting the repo 
print(repo)

For Github :

from github import Github  

g = Github(username,password)) 
repo = g.get_repo(repo_name)   # getting the repo 
print(repo)
mohit sehrawat
  • 171
  • 1
  • 12
3

For future readers who are security-minded like me and want a read-only Personal Access Token, to read your private repos, you will need this enabled (and the OP will have to generate a new token).

github PAT

Drakes
  • 23,254
  • 3
  • 51
  • 94
0

Which repo_name is used?

Example: team_X/repo_1

If using github() directly: repo = github().get_repo("team_X/repo_1")

If using org object to get repo: repo = org.get_repo("repo_1")

qloveshmily
  • 1,017
  • 9
  • 5