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

Catch BadCredentialsException #18

Open
mxmehl opened this issue May 2, 2024 · 0 comments
Open

Catch BadCredentialsException #18

mxmehl opened this issue May 2, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@mxmehl
Copy link
Member

mxmehl commented May 2, 2024

This error occurs if the GitHub token is invalid:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.[12](https://github.com/OpenRailAssociation/openrail-org-config/pull/3/checks#step:6:13).3/x64/bin/gh-org-mgr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/gh_org_mgr/manage.py", line 51, in main
    org.login(cfg_org.get("org_name", ""), cfg_app.get("github_token", ""))
  File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/gh_org_mgr/_gh_org.py", line 46, in login
    self.org = self.gh.get_organization(orgname)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/github/MainClass.py", line 396, in get_organization
    headers, data = self.__requester.requestJsonAndCheck("GET", f"/orgs/{login}")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/github/Requester.py", line 548, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/github/Requester.py", line 609, in __check
    raise self.createException(status, responseHeaders, data)
github.GithubException.BadCredentialsException: 401 {"message": "Bad credentials", "documentation_url": "https://docs.github.com/rest"}
Error: Process completed with exit code 1.
@mxmehl mxmehl added the enhancement New feature or request label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant