PyGitHub: Unable to access private repositories of my team

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?

Answers

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)
Posted on by mohit sehrawat

Relevant tags