File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed
Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change 1- # Created by sarathkaul on 14/11/19
1+ #!/usr/bin/env python3
2+
3+ """
4+ Created by sarathkaul on 14/11/19
5+
6+ Basic authentication using an API password is deprecated and will soon no longer work.
7+ Visit https://developer.github.com/changes/2020-02-14-deprecating-password-auth
8+ for more information around suggested workarounds and removal dates.
9+ """
10+
211
312import requests
413
514_GITHUB_API = "https://api.github.com/user"
615
716
8- def fetch_github_info (auth_user : str , auth_pass : str ) -> None :
9- # fetching github info using requests
10- info = requests .get (_GITHUB_API , auth = (auth_user , auth_pass ))
11-
12- for a_info , a_detail in info .json ().items ():
13- print (f"{ a_info } : { a_detail } " )
17+ def fetch_github_info (auth_user : str , auth_pass : str ) -> dict :
18+ """
19+ Fetch GitHub info of a user using the requests module
20+ """
21+ return requests .get (_GITHUB_API , auth = (auth_user , auth_pass )).json ()
1422
1523
16- if __name__ == "main" :
17- fetch_github_info ("<USER NAME>" , "<PASSWORD>" )
24+ if __name__ == "__main__" :
25+ for key , value in fetch_github_info ("<USER NAME>" , "<PASSWORD>" ).items ():
26+ print (f"{ key } : { value } " )
You can’t perform that action at this time.
0 commit comments