-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
I am writing a project that should be able to allow specific users to automatically perform some actions on some file contents after logging in. I tried to alter some of the code and I'm getting some strange behaviour.
I have scoured the internet and I am literally using the exact documented code as copy and pasted, yet it always returns: github.GithubException.GithubException: 401 {"message": "Requires authentication", "documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"}.
My username and password are correct before you ask. I have run my code with PATkey tokens to ensure the rest of it works, but I obviously cannot distribute those publicly. The passwordbox function will return the string password put into this, so this isn't the issue either. From what I gather, this code should run perfectly fine, but it doesn't for me:
https://pygithub.readthedocs.io/en/latest/introduction.html
https://stackoverflow.com/questions/46524697/login-problems-using-pygithub
I can't find any working examples of logging in with username and password, only tokens. Is it possible my code is not the issue?
Here is my code which causes the error:
from github import Github
from easygui import passwordbox # This works similarly to getpass, but works for pycharm without going to terminal.
def login():
# Ask for login details
username = input("Username? ")
_password = passwordbox("Please enter your password for user: {} ".format(username))
# Login
g = Github(username, _password)
del _password
user = g.get_user()
login = user.login
print("Login Successful!")
login()I hope that I'm an idiot and that the solution is simple. I understand that the initial github instance is unauthorised, but that error message tells that I am required to login before I login?! Surely