Skip to content

Commit fdc8631

Browse files
authored
Merge pull request #6 from KG-1510/master
Use case test script
2 parents e39bee6 + 8d81238 commit fdc8631

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

testScriptFinal.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import requests
2+
import json
3+
4+
def showRepos(username,apitoken):
5+
try:
6+
url = "https://api.github.com/users/"+username+"/repos"
7+
token = "Bearer "+apitoken
8+
headers = {"Authorization": token}
9+
r = requests.get (url, headers=headers)
10+
p = r.json()
11+
q = json.dumps(p, indent=4, sort_keys=True)
12+
dictVal = json.loads(q)
13+
info = str(r)
14+
15+
repCode = "<Response [200]>"
16+
17+
if(info==repCode):
18+
return dictVal
19+
else:
20+
print("Sorry! Try again after passing correct credentials!")
21+
return False
22+
23+
except:
24+
print("Sorry! Try again after passing correct credentials!")
25+
return False
26+
27+
showRepos("usernamehere","personalaccesstokenhere")
28+

0 commit comments

Comments
 (0)