4
votes

I am a member of an organization which has a lot of private repositories on GitHub. I need to use the GitHub API to get data from the private repositories. I am using the following python code:

url = "https://api.github.com/orgs/myorg/repos?access_token=[mytokenhere]"
headers = {"Authorization": "token [myPATHhere]"}
session = requests.Session()
response = session.get(url, headers = headers)
content = response.text

my_json = json.loads(response.text)


for item in my_json:
    print(item['html_url'])

Where PAT = my access token. This still only returns the public repositories. I've seen the related question but the listed solutions do not solve my problem. Note that I've authorized my access token to get into the private repository. I've also tried api.github.com/users/repos and api.github.com/users/[myorghere] and still no private repos are returned. Am I not submitted the token correctly?

1
Is this information useful for your situation? stackoverflow.com/questions/20396329/…Tanaike

1 Answers

2
votes

Go into your personal access token and ensure that you have selected the necessary scopes. The first one is for private repos so you may need to select some/all of the options there.