Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Fixes: #3944 authentication error #3949
Conversation
Pull Request Report@lawric1 Hello! I'm a bot made to check all the pull request Python files. First of all, I want to say thank you for your time and interest in this project and for opening a pull request. I have detected errors in some of the Python files submitted in this pull request. Please read through the report and make the necessary changes. You can take a look at the relevant links provided after the report. What are node paths?The report contain headings and a checklist where the items are paths to the class/function/parameter where the error is present. Node paths are double colon
Following functions require tests [
|
|
Please read the GitHub REST API documentation and apply the requested changes. Combine the module-level docstring into one and that should come first, before any of the imports. |
…tHub REST API standards
| Basic authentication using an API password is deprecated and will soon no longer work. | ||
| Visit https://developer.github.com/changes/2020-02-14-deprecating-password-auth | ||
| for more information around suggested workarounds and removal dates. |
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| for key, value in fetch_github_info("<USER NAME>", "<PASSWORD>").items(): | ||
| for key, value in fetch_github_info("<TOKEN>").items(): |
dhruvmanila
Nov 24, 2020
Member
It would be better to add a global constant TOKEN with the default value an empty string "" and asking the user to provide their token.
Check whether the TOKEN constant is empty or not and raise a ValueError stating the fact that we need a token to get an authenticated user.
| 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_token: str) -> dict: |
dhruvmanila
Nov 24, 2020
Member
The return type hint needs to be more descriptive.
Use from typing import Dict and specify it as: Dict[type(key), type(value)]
As we probably don't know what GitHub is going to give us we should probably specify it as Dict[Any, Any]
| """ | ||
| Fetch GitHub info of a user using the requests module | ||
| """ | ||
| return requests.get(_GITHUB_API, auth=(auth_user, auth_pass)).json() | ||
| token = {"Authorization": "token {}".format(auth_token)} |
dhruvmanila
Nov 24, 2020
Member
| token = {"Authorization": "token {}".format(auth_token)} | |
| token = {"Authorization": f"token {auth_token}"} |
Please use f-strings as mentioned in the Contributing guidelines.
Also, as suggested by GitHub, we should provide the Accept header value as well.
|
Thanks for all the feedback, this is my first time contributing and i'm learning a lot |


Fixes: #3944
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.