Skip to content

Instantly share code, notes, and snippets.

@dorneanu
Last active December 15, 2023 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dorneanu/d25e5eb327429095285fd6552486d064 to your computer and use it in GitHub Desktop.
Save dorneanu/d25e5eb327429095285fd6552486d064 to your computer and use it in GitHub Desktop.
Python: List all repos inside a organization using python and github3
# Make sure you authorize your access token to be used with SAML
# https://help.github.com/articles/authorizing-a-personal-access-token-for-use-with-a-saml-single-sign-on-organization/
#
# Run:
# python list_all_repos.py <org>
import github3
import os
GITHUB_ACCESS_TOKEN = os.environ["GITHUB_ACCESS_TOKEN"]
gh = github3.login(token=GITHUB_ACCESS_TOKEN)
org = gh.organization(os.argv[1])
repos = list(org.iter_repos(type="all"))
for r in repos:
print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment