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
Support full GitHub app authentication #1986
Support full GitHub app authentication #1986
Conversation
Codecov ReportBase: 98.75% // Head: 98.77% // Increases project coverage by
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #1986 +/- ##
==========================================
+ Coverage 98.75% 98.77% +0.01%
==========================================
Files 115 116 +1
Lines 11595 11669 +74
==========================================
+ Hits 11451 11526 +75
+ Misses 144 143 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments for easier reviewing.
@@ -125,3 +125,12 @@ | |||
|
|||
# https://developer.github.com/changes/2018-10-16-deployments-environments-states-and-auto-inactive-updates/ | |||
deploymentStatusEnhancementsPreview = "application/vnd.github.flash-preview+json" | |||
|
|||
|
|||
DEFAULT_BASE_URL = "https://api.github.com" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved those here since they are used in 2 files now (MainClass
and GithubIntegration
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing this is really difficult. Would have been better to do the refactoring (without changes) in a separate PR and base this PR on that. Then we would see only changes, not moving unchanged code around.
github/GithubException.py
Outdated
@@ -38,7 +38,7 @@ class GithubException(Exception): | |||
Some other types of exceptions might be raised by underlying libraries, for example for network-related issues. | |||
""" | |||
|
|||
def __init__(self, status, data, headers): | |||
def __init__(self, status, data, headers=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a 404 while testing and had an exception because the headers parameters was not passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a fix there for the same issue: #2079
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think fixing the calling code as in #2079 is better than changing the signature.
@@ -0,0 +1,140 @@ | |||
import time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from MainClass
, it's already big as it is and that does not really belong there.
status=response.status_code, data=response.text | ||
) | ||
|
||
@deprecated.deprecated("Use get_repo_installation") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if that does not suit you. I feel that this call is badly named
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the existing call? It should probably also state it's deprecated in the docstring. Also, it should mention the class, not just the bare function.
def get_repo_installation(self, owner, repo): | ||
return self.get_installation(owner, repo) | ||
|
||
def get_installations(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part I added in that file. Users having a private app with more than one installations can use this call as the main class always uses the first found installation.
@@ -304,6 +310,9 @@ def __init__( | |||
): | |||
self._initializeDebugFeature() | |||
|
|||
self.__installation_authorization = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The heart of the changes I made is here!
also very interested in seeing this implemented, are there any updates on this feature? |
Will this be integrated? |
@s-t-e-v-e-n-k sorry to ping you directly; there hasn't been any feedback from the maintainers on this PR for close to a month now and I'm not sure who's in charge. What can we do to speed up things and help you out? |
Would also really like to see this feature! How can we help? |
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. |
Hi, Could you merge this PR? |
Would definitely appreciate this feature being merged in |
github/GithubException.py
Outdated
@@ -38,7 +38,7 @@ class GithubException(Exception): | |||
Some other types of exceptions might be raised by underlying libraries, for example for network-related issues. | |||
""" | |||
|
|||
def __init__(self, status, data, headers): | |||
def __init__(self, status, data, headers=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think fixing the calling code as in #2079 is better than changing the signature.
Thanks for the review! I made the requested changes. |
@EnricoMi @ThomasJRyan Anything else I should do? |
I went and look at all the files I changed to make sure there were no default values left in pyi. Crossing my fingers that everything is ok now 🤞 |
I hate to ask again, but is it all good? I'm looking forward to go back to using the official library instead of our fork. Thanks for your work maintaining this library! |
…on' into feature/github-app-authentication
That is fixed. I must say I find the imports in this project to be done in a peculiar fashion. |
Agreed. I tend to go all out in refactoring as you've seen with the unrelated changes. I'll know to do that in the future. Thank you both for the reviews! |
All good now? I'm excited to see this release :) |
@dblanchette can you please take a look at #2420 / #2425? |
@dblanchette another issue likely being introduced by this PR: #2431 |
Another issue: #2432 |
This is quite some fallout, another issue reported: #2436 |
This adds support for GitHub App authentication using the main class which is simpler for users (see #1855)
Also, the credentials are refreshed when needed (tokens lasts for one hour). This should happen transparently to the users, as the token expiration is checked at every call.
Caveats and other notes:
GithubIntegration
, so I skipped that part. Manual testing works and existing tests are not broken