Skip to content

Fixes: #3944 authentication error #3949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Nov 25, 2020
Merged
13 changes: 9 additions & 4 deletions web_programming/fetch_github_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
import requests

"""
Created by sarathkaul on 14/11/19
Expand All @@ -8,19 +9,23 @@
for more information around suggested workarounds and removal dates.
"""

"""
Created by lawric1 on 24/11/20

To generate your personal access token visit https://github.com/settings/tokens
"""

import requests

_GITHUB_API = "https://api.github.com/user"


def fetch_github_info(auth_user: str, auth_pass: str) -> dict:
def fetch_github_info(auth_user: str, auth_token: str) -> dict:
"""
Fetch GitHub info of a user using the requests module
"""
return requests.get(_GITHUB_API, auth=(auth_user, auth_pass)).json()
return requests.get(_GITHUB_API, auth=(auth_user, auth_token)).json()


if __name__ == "__main__":
for key, value in fetch_github_info("<USER NAME>", "<PASSWORD>").items():
for key, value in fetch_github_info("<USER NAME>", "<TOKEN>").items():
print(f"{key}: {value}")