from urllib.request import urlopen, Request
url = 'https://api.github.com/users/vhf/repos'
token = 'my_personal_access_token'
request = Request(url)
request.add_header('Authorization', 'token %s' % token)
response = urlopen(request)
print(response.read())
Access Github API using Personal Access Token with Python urllib2