mattduck / gh2md

Export Github repository issues, pull requests and comments to markdown.
MIT License
254 stars 45 forks source link

Issue on macOS #18

Closed nclm closed 3 years ago

nclm commented 3 years ago

I tried using gh2md on the computer here at work (running macOS 11.1) and all I get is this:

nicolas@computer ~ % gh2md user/project issues.md --login user
Github password for user :
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/bin/gh2md", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/gh2md/gh2md.py", line 41, in main
    fetch_repo_and_export_to_markdown(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/gh2md/gh2md.py", line 139, in fetch_repo_and_export_to_markdown
    repo, github_api = get_github_repo(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/gh2md/gh2md.py", line 286, in get_github_repo
    return gh_owner.get_repo(repo_name), gh
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/github/NamedUser.py", line 545, in get_repo
    headers, data = self._requester.requestJsonAndCheck(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/github/Requester.py", line 353, in requestJsonAndCheck
    return self.__check(
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/github/Requester.py", line 378, in __check
    raise self.__createException(status, responseHeaders, output)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/reference/repos#get-a-repository"}

python --version is Python 2.7.16, python3 --version is Python 3.9.5.

Any idea of what is happening? Thanks!

mattduck commented 3 years ago

@nclm hey, sorry for slow response here.

I need to look at this more but I was able to reproduce it on my account by trying to clone a private repository using password login. I'm pretty sure this is because it doesn't handle 2FA login properly right now, and so probably I get the 404 because I'm not authenticated.

Do you have 2FA on your account? If so you can pass in an access token using one of:

There are a couple of things I'll look at here:

  1. 2FA login support
  2. Better error handling to make it clear what's happening

If this is a public repo or you don't have 2FA on your account then let me know.

mattduck commented 3 years ago

@nclm OK I looked into this properly today. It turns out that Github no longer supports username + password login authentication, and the API is returning its standard 404 response that it gives when the user isn't authenticated (https://docs.github.com/en/rest/overview/other-authentication-methods#basic-authentication).

I haven't been super active maintaining this so had missed the news last year that they were removing this. Apologies.

If you use a personal access token with the "repo" scope it should work fine for private repositories.

I've just released a new version, and now token authentication is required (unless your repo is public, in which case you don't strictly need to authenticate).

Going to close this but LMK if you still have issues.