Skip to content

Instantly share code, notes, and snippets.

Created April 6, 2017 21:12
  • Star 18 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Simple GitHub API example using python and personal access token
import requests
import json
# inputs
username = ''
# from
token = ''
repos_url = ''
# create a re-usable session object with the user creds in-built
gh_session = requests.Session()
gh_session.auth = (username, token)
# get the list of repos belonging to me
repos = json.loads(gh_session.get(repos_url).text)
# print the repo names
for repo in repos:
print repo['name']
# make more requests using "gh_session" to create repos, list issues, etc.
Copy link

This doesn't work anymore. {'message': 'Bad credentials', 'documentation_url': ''}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment