Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BadCredentialsException not raised on GitHub enterprise #934

Closed
slinkymanbyday opened this issue Oct 17, 2018 · 7 comments
Closed

BadCredentialsException not raised on GitHub enterprise #934

slinkymanbyday opened this issue Oct 17, 2018 · 7 comments
Labels

Comments

@slinkymanbyday
Copy link

On Github Enterprise, the API message does not read "Bad credentials" when incorrect credentials are supplied. It reads "Must authenticate to access this API."

Might be better to just go off of the 401 code as opposed to the error message.

if status == 401 and output.get("message") == "Bad credentials":

should be
if status == 401:

@sfdye
Copy link
Member

sfdye commented Oct 17, 2018

PR please I will review

@Zoom67
Copy link

Zoom67 commented Nov 7, 2018

I think this may have broken something. If I run v1.43.2, my script works; if I run 1.43.3, I get 401 {u'documentation_url': u'https://developer.github.com/v3', u'message': u'Bad credentials'}. The credentials are good.

@sfdye
Copy link
Member

sfdye commented Nov 8, 2018

@Zoom67 Can you share the script?

@Zoom67
Copy link

Zoom67 commented Nov 8, 2018

I can share a snippet with some values fudged. It's very simple. Creating this object throws an exception, and the error message contains the JSON above.

from github import Github

class GitConnection(object):
    base_url = 'https://<our-gh-server>/api/v3'
    repo_id = '<repo-name>'

    def __init__(self, username, password):
        self._connection = Github(username, password, self.base_url)
        self._repo = self._connection.get_repo(self.repo_id)

@sfdye
Copy link
Member

sfdye commented Nov 8, 2018

@Zoom67 Found the culprit #948

This PR changes the relative positions of the arguments, so you might want to use keyword arguments instead of positional ones.

This should solve your problem:
self._connection = Github(username, password, base_url=self.base_url)

@Zoom67
Copy link

Zoom67 commented Nov 8, 2018

Yep, that did it - thanks! I changed that line to be fully qualified, just to be sure.

        self._connection = Github(login_or_token=username,
                                  password=password,
                                  base_url=self.base_url)

@stale
Copy link

stale bot commented Jan 7, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 7, 2019
@stale stale bot closed this as completed Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants