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

Reattaching an entity to another client instance #1656

Open
Haarolean opened this issue May 7, 2023 · 4 comments
Open

Reattaching an entity to another client instance #1656

Haarolean opened this issue May 7, 2023 · 4 comments

Comments

@Haarolean
Copy link
Contributor

Haarolean commented May 7, 2023

Hi,

I've got a situation like this:

  1. My app does listen to incoming webhooks, I parse the payload with an instance of a client authenticated as an app with a JWT token.
  2. After that, once I realize which type of payload I have I fetch some info, like an issue from the payload and I have to do additional things which require app installation authentication.

With this approach I get stuck with an instance of GHIssue fetch via and tied to a client instance authenticated as an app, but in order to do other things I have to reauthenticate as an app installation. I couldn't find a way to do this. A dirty approach would be changing root of the issue instance's GitHubInteractiveObject, but the field is r/o.
Is there a way to do this now, am I missing something?
if not, mind any suggestions? I'd suggest implementing a method to "rebind" an entity (GitHubInteractiveObject) to another provided instance of a github client. Any possible issues with that approach?

@gsmet
Copy link
Contributor

gsmet commented May 10, 2023

Hi,

My advice would be to NOT parse the whole payload at first. Read the JSON, extract what you need and then parse the payload. That's what I'm doing.

If you don't want to bother about all this, have a look at my Quarkus GitHub App project (https://github.com/quarkiverse/quarkus-github-app), it handles all the heavy-lifting for you and doesn't require much knowledge about Quarkus.
It has an extensive documentation which guides you through all the steps here: https://quarkiverse.github.io/quarkiverse-docs/quarkus-github-app/dev/index.html .

It is based on the Hub4j GitHub API for all the GitHub interactions (and you also can do GraphQL if you need to as not everything is exposed through the REST API these days).

And it supports GitHub Enterprise too.

I'll be happy to help in the discussions of the project (https://github.com/quarkiverse/quarkus-github-app/discussions) if you need help.

@Haarolean
Copy link
Contributor Author

@gsmet I can imagine another situation in which app installation auth is not required at the moment, but later it would be depending on business logic, so the problem persists.

@gsmet
Copy link
Contributor

gsmet commented May 10, 2023

My personal experience is that if you're dealing with webhooks, being in the context of a GitHub App with an installation is far more practical. But YMMV :).

@Haarolean
Copy link
Contributor Author

@gsmet

I believe that there should be probably two modes of parsing the payload -- lazy and eager.
So in order to do a full eager one with an app with installation I could already have the data I'd need (repo owner, repo name, etc).
Otherwise, It's just really frustrating, I need to tear out a lot of data myself (in different ways for different payloads!) just to proceed to business logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants