Github "Requires Authentication" Error when using PyGithub

I was trying to figure out how to use the PyGithub module, but I keep getting the same error:

github.GithubException.GithubException: 401 {"message": "Requires authentication", "documentation_url": "

My code is pretty simple, considering I just started out:

from github import Github
g = Github("Charonum","xxxxxxxx")
user = g.get_user()

The error is when it gets to print(


Looking at their docs it doesn't look like you're initializing the Github class correctly. I would read through that to find more about how to properly setup. The error is pretty clear that you don't have your auth credentials input properly

Example from the docs

from github import Github

# using an access token
g = Github("access_token")

# Github Enterprise with custom hostname
g = Github(base_url="https://{hostname}/api/v3", login_or_token="access_token")
Posted on by sedavidw