-
Notifications
You must be signed in to change notification settings - Fork 0
/
accessgithub.py
35 lines (28 loc) · 942 Bytes
/
accessgithub.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import json
username = 'connolr3'
# from https://github.com/user/settings/tokens
# authentication to GitHub when using the GitHub API
token = ''
# 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_url = 'https://api.github.com/user/repos'
repos = json.loads(gh_session.get(repos_url).text)
# print the repo names
print ("Repo Names")
i = 0
for repo in repos:
print (repos[i]['name'])
i+=1
# get my user details
user_url = 'https://api.github.com/user'
user = json.loads(gh_session.get(user_url).text)
#PRINT USER DETAILS
print ("Name: "+user["name"])
print ("Username: "+user["login"])
print ("URL: "+user["url"])
print ("Bio: "+user["bio"])
print ("Following (no. accounts):" + str(user["following"]))
print ("Creation Date: "+user["created_at"])