Created
May 1, 2019 18:01
-
-
Save jeremywarrick/e98df07d2808888146a1441b2cd13c4e to your computer and use it in GitHub Desktop.
Quick python3 code to list all the repositories in a GitHub organization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
user = 'user name here' | |
token = 'token here' | |
url = "https://api.github.com/orgs/<organization_name>/repos" | |
session = requests.Session() | |
session.auth = (user, token) | |
headers = {'Authorization': 'token %s' % token} | |
r = requests.get(url, headers=headers) | |
repos = r.json() | |
while 'next' in r.links.keys(): | |
r = requests.get(r.links['next']['url'],headers=headers) | |
repos.extend(r.json()) | |
for repo in repos: | |
print(repo['full_name']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment