-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Description
Is there anyone using this method? The only other reference to my issue is two comments in this stale pull request #1791 which seems to agree with my findings. Alternatively, we are both guilty of user error.
To recreate the issue:
- Create a github app with read access to repositories.
- Install it in your user account granting access to all repositories, or at least one private repo used for this example.
- Create and download an application private key ".pem" file.
- Note the application ID.
Initialize the integration and installation. Ensure that the installation credentials work for mundane requests (get repo).
$ python3
Python 3.11.2 (main, Feb 16 2023, 03:07:35) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
>> from github import *
>> with open("mykeyfile.pem", "r") as f:
... private_key = f.read().strip()
>> app_id = "123456" // use your application id.
>> integration = github.GithubIntegration(app_id, private_key)
>> installation = integration.get_repo_installation('myuser', 'my-private-repo')
>> token = integration.get_access_token(installation.id).token
>> g = Github(token)
>> g.get_repo('myuser/my-private-repo')
Repository(full_name="myuser/my-private-repo")
The failure
>> print('Using the same installation, I get this failure')
>> installation.get_repos()
<github.PaginatedList.PaginatedList object at 0x11248d450>
>>> hitting_the_api_now = [r for r in installation.get_repos()]
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <listcomp>
File "/users/Ubuntu/test_error/.venv/lib/python3.11/site-packages/github/PaginatedList.py", line 56, in __iter__
newElements = self._grow()
^^^^^^^^^^^^
File "/users/Ubuntu/test_error/.venv/lib/python3.11/site-packages/github/PaginatedList.py", line 67, in _grow
newElements = self._fetchNextPage()
^^^^^^^^^^^^^^^^^^^^^
File "/users/Ubuntu/test_error/.venv/lib/python3.11/site-packages/github/PaginatedList.py", line 201, in _fetchNextPage
headers, data = self.__requester.requestJsonAndCheck(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/users/Ubuntu/test_error/.venv/lib/python3.11/site-packages/github/Requester.py", line 398, in requestJsonAndCheck
return self.__check(
^^^^^^^^^^^^^
File "/users/Ubuntu/test_error/.venv/lib/python3.11/site-packages/github/Requester.py", line 423, in __check
raise self.__createException(status, responseHeaders, output)
github.GithubException.BadCredentialsException: 401 {"message": "Bad credentials", "documentation_url": "https://docs.github.com/rest"}
Metadata
Metadata
Assignees
Labels
No labels