How do i properly authenticate to the github Api v3 using pyGithub. getting bad credentials error

1.6k Views Asked by At

I'm trying to use the Pygithub library for python to access my repositories through the github API v3. I'm following the tutorial given by the documentation and storing my credentials in another file called credentials. I checked to see that these were correctly loaded and they were. they're formatted as "user" and "password" so nothing else except my actual username and my actual pass.

this is the code

from github import Github
credentials = open("credentials")
user = credentials.readline()
Pass = credentials.readline()
clientId = credentials.readline()
credentials.close()
git = Github(user,Pass)
repos = [ _ for _ in git.get_user().get_repos()]

code error received

Is there anything else i should add to the user and password string? I don't get why I'm getting this error and i can't find anything about it in the docs or from other questions?

1

There are 1 best solutions below

0
On

I solved it. I forgot to strip my credentials from their breaklines. which is why the API kept telling me bad credentials. A quick debug told me this. (stupid enough to have done this many times, instead of debugging i print the lines i receive but this doesn't print breaklines ofcourse)