Enable client reuse when authenticating with app user access tokens #740
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows octocrab instances to be reused with different Github app user access tokens, similar the
installation
function enabling an instance to be reused with different installations of an app.The motivation is to avoid creating a new connection every time a request needs made for a different user, user access token. I didn't see any good way to reuse or provide the connection created in
build
(code)Here's how it looks:
An alternative is to expose an
Octocrab::toBuilder
method to effectively clone the existing client with varying configuration. This looks hard given how configuration ends up embedded in service layers.User access token documentation: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app